[英]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?有人会知道可以使用正则表达式(在记事本++中)来替换每行中第一次出现的字符组?
eg:例如:
abcdefg//ijkl//m.
qsdflkj//sdqlmkf//jqsmdl.
to到
abcdefg\\ijkl//m.
qsdflkj\\sdqlmkf//jqsmdl.
so replace //
by \\\\
in each line, but only the first occurence of , not the next.所以在每一行中用
\\\\
替换//
,但只有第一次出现,而不是下一次。
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.
如果没有,我将编写一个程序来分割线并完成这项工作,但需要更多时间。
Thnaks in advance.提前谢谢。
Enter this regex in Find what
field在
Find what
字段中输入此正则表达式
(.*?)//(.*)
Enter this in Replace with
field在
Replace with
字段中输入此内容
$1\\$2
Select Regular expression
in Search Mode
and Uncheck . matches newline
在
Search Mode
选择Regular expression
并取消选中. matches newline
. matches newline
^[^/]+\\K//
^[^/]+\\K//
\\\\\\\\
\\\\\\\\
Explanation:说明:
^ : begining of line
[^/]+ : 1 or more any character that is not a slash
\K : forget all we have seen until this position
// : 2 slashes
Replacement:更换:
\\\\ : 2 backslashes, each one must be escaped
Result for given example:给定示例的结果:
abcdefg\\ijkl//m.
qsdflkj\\sdqlmkf//jqsmdl.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.