小编use*_*770的帖子

python 中的 \b 和精确单词匹配

如何使 \b 正确尊重单词边界?例如,理解 ' 并且不进行部分匹配...

>>> import re
>>> str = "This is a test's test"
>>> p1 = r'\b' + 'test' + r'\b'
>>> re.findall(p1,str)
['test', 'test']
Run Code Online (Sandbox Code Playgroud)

python regex string

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

regex ×1

string ×1