Reputation: 1885
Using Notepad++ v6.5.5
I have the following regex:
((?<=,)[,\ \/\-#\w]{2,}(?=,[0-9]))
I'm trying to capture the text Dow Corning / Molykote 111, Valve Lubricant
in the following row:
111,Dow Corning / Molykote 111, Valve Lubricant,25.000000,Y,46.010000,1,1 MSRP
It captures just fine, but I can't seem to reference the replace group.
I've tried the following:
"$0"
"$1"
"$2"
"$3"
"\0"
"\1"
"\2"
"\3"
\1 = "\1"
And I've also moved the parentheses to inside of the lookahead and lookbehind:
(?<=,)([,\ \/\-#\w]{2,})(?=,[0-9])
I attempted to replace the text with the following gibberish:
ansfnasflknsf
Nothing is being replaced. Not sure what's going on, really. I can use find/replace just fine with plain text, but not regex.
Gah, just tried v6.4.5 and it still didn't work.
If someone gets this to work, can they let me know what version they're using?
The following regex is a little better for capturing what I need:
((?<=,)(?<!\ )[,\ \/\-#\w]{2,}(?=,[0-9\.]+))
Upvotes: 3
Views: 4165
Reputation: 1759
Just $1
will work. $0
references the whole original string. (My N++ version is 6.6.9.)
Upvotes: 3
Reputation: 89629
With a reasonable recent version of notepad++ you can do that:
find: ^[^,]*,\K.+?(?=,[0-9.]+,)
replace: "$0"
Upvotes: 1