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")
我得到了“不匹配”。任何想法出了什么问题?