但是,如果您需要在字符串中查找所有正则表达式匹配项,请使用该
findall函数。
import reline = 'bla bla bla<form>Form 1</form> some text...<form>Form 2</form> more text?'matches = re.findall('<form>(.*?)</form>', line, re.DOTALL)print(matches)# Output: ['Form 1', 'Form 2']
但是,如果您需要在字符串中查找所有正则表达式匹配项,请使用该
findall函数。
import reline = 'bla bla bla<form>Form 1</form> some text...<form>Form 2</form> more text?'matches = re.findall('<form>(.*?)</form>', line, re.DOTALL)print(matches)# Output: ['Form 1', 'Form 2']