为什么正则表达式“java”与Python的re模块不匹配“/something.java”?

时间:2016-09-09 16:03:06

标签: python regex pattern-matching match

这是代码:

import re
regex = re.compile('java')
print regex.match('/something.java')

这是输出:

  

1 个答案:

答案 0 :(得分:1)

因为python匹配从头开始匹配。看到 python -- re.match vs. re.search 如果你想使用匹配,你需要使用模式.*java

相关问题