[英]Regex replace within match
In Notepad++ RegEx, I want to search for all strings starting with a tilde and terminating with \\n, and within each match replace all spaces with non-breaking spaces. 在Notepad ++ RegEx中,我要搜索所有以代字号开头并以\\ n结尾的字符串,并且在每个匹配项内用不间断空格替换所有空格。
That is, I want to find all instances of \\~.*^
, and within the resulting $0
, replace all [Space]s
with [Non-breaking Space]
. 也就是说,我想找到
\\~.*^
所有实例,并在生成的$0
,将所有[Space]s
替换为[Non-breaking Space]
。
Is this possible? 这可能吗?
With fixed-width pattern lookbehind regex engines (eg, Perl): 在正则表达式引擎(例如Perl)后面使用固定宽度模式:
s/(~.*?) {2,}/\1 /g
with variable-width pattern lookbehind regex engines: 在正则表达式引擎后面具有可变宽度模式:
s/(?<=\~.*) {2,}/ /g
or with Vim: 或使用Vim:
s/\(\~.*\)@<= \{2,}/ /g
I'm not sure about Notepad++. 我不确定Notepad ++。 Hopefully you can work it out based on the above.
希望您可以根据以上内容进行解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.