import re
# Precompile the patterns
regexes = [
re测试数据pile(p)
for p in ['this', 'that']
]
text = 'http://blog.csdn.net/caimouse is great blog, this is my blog.'
print('Text: {!r}\n'.format(text))
for regex in regexes:
print('Seeking "{}" ->'.format(regex.pattern),
end=' ')
if regex.search(text):
print('match!')
else:
print('no match') Text: 'http://blog.csdn.net/caimouse is great blog, this is my blog.' Seeking "this" -> match! Seeking "that" -> no match
以上就是python编译正则表达式提高效率方法详解的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于python编译正则表达式提高效率方法详解的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did84423