python正则表达式也匹配特殊字符
目前我使用这个简单的脚本来搜索字符串中的标记python正则表达式也匹配特殊字符,python,regex,Python,Regex,目前我使用这个简单的脚本来搜索字符串中的标记 tag = "#tag" text = "test string with #tag inserted" match = re.search(tag, text, re.IGNORECASE) #matches 现在假设文本包含一个a-acute tag = "#tag" text = "test string with #tág inserted" match = re.search(tag, text, re.IGNORECASE) #does
tag = "#tag"
text = "test string with #tag inserted"
match = re.search(tag, text, re.IGNORECASE) #matches
现在假设文本包含一个a-acute
tag = "#tag"
text = "test string with #tág inserted"
match = re.search(tag, text, re.IGNORECASE) #does not match :(
我如何使这场比赛有效?应该也适用于其他特殊角色(è、è、è等)
提前谢谢 您可以使用以下方法规范化文本: out:
['#tag', '#tag']
unidecode
不是标准的Python库。你能发布一个链接吗?这并不能说明'tag'
本身可能在字符串中。@Volatility--我不确定我是否明白,你能详细说明一下吗。嗯,现在我已经读过这个问题了。。。我以为OP想要找到所有的“#tág”
s,而不是“#tag”
——很明显我看错了,对不起;)“其他特殊角色”是否包括以下内容∆ 或Ж或新 ?
['#tag', '#tag']