版权声明:凡由本人原创,如有转载请注明出处https://me.csdn.net/qq_41424519,谢谢合作 https://blog.csdn.net/qq_41424519/article/details/81978031
import re
patterns = ['that', 'this' ]
text = 'Does this text match the pattern?'
for pattern in patterns:
print('Looking for "%s" in "%s" ->' % (pattern, text),)
if re.search(pattern, text):
print ('found a match!')
else:
print ('no match')