我使用regex101.com来测试正则表达式中的字符串。Python re不同的结果
我在网站上使用的代码是这样的:
Regular expression = nv[_](.*)[_]
Test string http://www.imdb.com/chart/top?ref_=nv_mv_250_6
在我的Python,当我使用建议的代码,而不必mv_250我已经nv_mv_250_
的由网站推荐的代码是这个
import re
p = re.compile(ur'nv[_](.*)[_]')
test_str = u"http://www.imdb.com/chart/top?ref_=nv_mv_250_6"
re.search(p, test_str)
为什么结果不一样?
该值在'.group(1)'中。 –