import re # unicode 编码匹配范围[u4e00-u9fa5] pattern = re.compile('(w+) (w+)') s = 'hello 123,hello 456' s_list = pattern.findall(s) print(s_list) s_list = pattern.sub('hello world',s) print(s_list)
import re # unicode 编码匹配范围[u4e00-u9fa5] pattern = re.compile('(w+) (w+)') s = 'hello 123,hello 456' s_list = pattern.findall(s) print(s_list) s_list = pattern.sub('hello world',s) print(s_list)