简体   繁体   中英

Notepad++: regex as replace

I'm busy inserting my url aliases into a database. 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. 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). 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=)\d+('\s*,\s*')(\d+)

You can use this.Replace by $2$1$2 or \\2\\1\\2 .See demo.

https://regex101.com/r/lR1eC9/4

Was a little tricky but here is how you can do it:

\d+(',')(\d+)

and replace with

$2$1$2

One picture == thousand words

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM