0
我想匹配方括號內的數據時間,我認爲前綴「\」將編碼方括號的方式,但它不工作。這裏是我的代碼:Python的正則表達式匹配方括號isse
import re
line_nginx = re.compile(r"""\[(?P<time_local>\S+) -700\]""", re.IGNORECASE)
match = line_nginx.match("[07/Oct/2014:19:43:08 -0700]")
if match:
print("matched")
else:
print("no match")
我得到了「不匹配」。任何想法出了什麼問題?