我正在执行这个。
print(re.findall(r'(<OR|<PP).*>', '<OR first><PP second><OR third>'))
预期的:
['<OR first>', '<PP second>', '<OR third>']
实际的:
['<OR']
有谁知道我能达到预期的目标吗?
import re
print(re.findall(r'(?:<OR|<PP)[^>]*>', '<OR first><PP second><OR third>'))
注意
.*
贪婪地匹配,因此您的模式匹配整个字符串本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句