Notepad++ - 正则表达式:替换每行中第一次出现的字符组 [英] Notepad++ - regex : replace first occurrence of a characters group in each line
问题描述
有人会知道可以使用正则表达式(在记事本++中)来替换每行中第一次出现的字符组?
Someone would know the regex expression can be used (in notepad++) in order to replace the first occurence of a characters group in each line?
例如:
abcdefg//ijkl//m.
qsdflkj//sdqlmkf//jqsmdl.
到
abcdefg\\ijkl//m.
qsdflkj\\sdqlmkf//jqsmdl.
因此在每一行中将 //
替换为 \\
,但只有第一次出现,而不是下一次.
so replace //
by \\
in each line, but only the first occurence of , not the next.
如果regex不能实现,用notepad有没有别的方法.如果没有,我会编写一个程序来分割线并完成这项工作,但需要更多时间.
If regex can't achieve it, is there another method with notepad. If not, I will code a program to split line and do the job, but need more time.
提前致谢.
推荐答案
在 Find what
字段中输入此正则表达式
Enter this regex in Find what
field
(.*?)//(.*)
在 Replace with
字段中输入此内容
Enter this in Replace with
field
$1\\$2
在Search Mode
中选择Regular expression
并取消选中.匹配换行符
Select Regular expression
in Search Mode
and Uncheck . matches newline
这篇关于Notepad++ - 正则表达式:替换每行中第一次出现的字符组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!