2024-04-24 06:31:09 发布
网友
您需要以下regex:
\bold\b
>>> import re >>> s = "old string oldstring boldstring bold" >>> re.sub(r'\bold\b', 'new', s) 'new string oldstring boldstring bold'
这是通过使用word boundaries完成的。不用说,这个regex不是特定于Python的,并且是在大多数regex引擎中实现的。
您需要以下regex:
这是通过使用word boundaries完成的。不用说,这个regex不是特定于Python的,并且是在大多数regex引擎中实现的。
相关问题 更多 >
编程相关推荐