我使用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)'中。 –