[英]How to replace strings only in the string and numbers combination between double quotation Notepad++?
I'm trying to replace 「g」 with 「k」 in some article :我试图在一些文章中用“k”替换“g”:
this is "g1"..., and "g2" is......, last "g1034" shows that...
the end result will be最终结果将是
this is "k1"..., and "k2" is......, last "k1034" shows that...
I'm using the following regex to find the pattern :我正在使用以下正则表达式来查找模式:
"([^"]*)"
but fail to replace with success.但未能成功取代。
How can I do a replacement?我该如何更换? thx in advance提前谢谢
One option is to use一种选择是使用
"\Kg(?=\d+")
"
Match "
"
匹配"
\\Kg
Forget what is currenly matched using \\K
, then match g
\\Kg
忘记当前使用\\K
匹配的内容,然后匹配g
(?=\\d+")
Positive lookahead, assert what is on the right is 1+ digits and "
(?=\\d+")
正向前瞻,断言右边是 1+ 位数字和"
And replace with k
并替换为k
Another option could be using capturing groups另一种选择可能是使用捕获组
(")g(\d+")
In the replacement use the 2 groups在替换中使用 2 组
$1k$2
Note that if you do not want to match only digits, you could use [^"]+
instead of \\d+
to match at least 1 char after g
or use *
to match 0 or more chars after g
请注意,如果您不想只匹配数字,则可以使用[^"]+
而不是\\d+
匹配g
后至少 1 个字符或使用*
匹配g
后的 0 个或多个字符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.