[英]Notepad++: regex as replace
I'm busy inserting my url aliases into a database.我正忙于将我的 url 别名插入到数据库中。 And need to make insert queries from the list of values i have.
并且需要从我拥有的值列表中进行插入查询。
A few items from my list:我的清单中的一些项目:
(NULL, 'tag=23525','2807016'),
(NULL, 'tag=23525','10165'),
(NULL, 'tag=23525','12165'),
I'd love to have a regex expression which can find tag=23525 and can replace it with the number behind it.我很想有一个正则表达式,它可以找到 tag=23525 并且可以用它后面的数字替换它。 So the list will end up looking like this:
所以列表最终会是这样的:
(NULL, 'tag=2807016','2807016'),
(NULL, 'tag=10165','10165'),
(NULL, 'tag=12165','12165'),
I've managed to find the text tag=23525 (wow so hard).我设法找到了 text tag=23525 (哇太难了)。 But i'm stuck with the finding (the replace) of the number behind.
但我坚持寻找(替换)后面的数字。
I can find the last number easily with this regex but can't replace with this regex:我可以用这个正则表达式轻松找到最后一个数字,但不能用这个正则表达式替换:
^[^,]*,[^,]*,[^,]*\\b(\\w+)\\b
How am i able to find and replace tag=23525
with the match found from the regex?我如何才能找到并替换
tag=23525
与从正则表达式中找到的匹配项?
(?<=tag=)\d+('\s*,\s*')(\d+)
You can use this.Replace by $2$1$2
or \\2\\1\\2
.See demo.您可以使用 this.Replace by
$2$1$2
或\\2\\1\\2
参见演示。
https://regex101.com/r/lR1eC9/4 https://regex101.com/r/lR1eC9/4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.