1
我有一个日志中的短语列表,我想验证使用以下正则表达式的名称。 phrase
是一个有效的东西,但我仍然失败了。谁能告诉我这有什么问题?Python的正则表达式字,IP和端口组合匹配
非常感谢!
phrase = "ServerName.192.168.12.12.52915"
regex = re.compile("\bServerName\.\^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,5}$")
res = regex.match(phrase)
if test:
print "pass"
else:
print "fail"
你输入没有脱字符,你的模式有'\ ^'。看看[这里](https://regex101.com/r/kQ7lW1/2)。在模式开始时甚至不需要任何'\ b'。 –
谢谢。错过是一件容易的事情。 –