在python中,我需要用"-"
替换" - "
,但前提是[SPACE][DASH][SPACE]
出现在两个单词之间
[SPACE][SPACE][DASH][SPACE][SPACE]
不会更改。即:
" - The quick - brown fox jumps - over the -"
必须更改为
" - The quick-brown fox jumps - over the -"
This is jumps[SPACE][SPACE][DASH][SPACE][SPACE] ...
我不能把我的头缠在正则表达式上
Tags:
在@anubhavva的帮助下,我构建了这个通用函数:
您可以使用此正则表达式搜索单词边界:
RegEx Demo
由于两边都有单词边界,所以只有当空格被两边的单词字符包围时才匹配
代码:
相关问题 更多 >
编程相关推荐