import re
pattern = re.compile(r’hello’)
self.PATTERN = re.compile(r’hello’)
res = re.match(pattern,string)
其中match只从0位置匹配
res = re.search(pattern,string)
search可以从多个位置匹配
另一种用法
res = pattern.search(string)
少写了一个re,而且感觉更清晰了
import re
pattern = re.compile(r’hello’)
self.PATTERN = re.compile(r’hello’)
res = re.match(pattern,string)
其中match只从0位置匹配
res = re.search(pattern,string)
search可以从多个位置匹配
另一种用法
res = pattern.search(string)
少写了一个re,而且感觉更清晰了