lconnell
asked on
RegEx N'th Occurrence using Sublime
I have already asked a similar question here: Regex
I have this regex working within VI which replaces the 3rd occurrence of ',' with 'Unique,'
I can't seem to get it to work within Sublime Text Editor. I have tried the following regex, but it doesn't replace the 3rd comma, it instead captures it and places it into my replacement string.
Sample Data: echo "clientRequests#300#raw,$E POCH_TIME, $_importEx ternalEmai lData,proj _ott,ottco re
Regex Find: (,.*?,.*?,)
Replace Str: $1Unique
I want to find the 3rd comma so I can append to the name $_importExternalEmailData so the result is $_importExternalEmailDataU nique. Right now it will put 'Unique' after the 3rd comma.
I have this regex working within VI which replaces the 3rd occurrence of ',' with 'Unique,'
s/,.\{-},.\{-}\zs,/Unique,
I can't seem to get it to work within Sublime Text Editor. I have tried the following regex, but it doesn't replace the 3rd comma, it instead captures it and places it into my replacement string.
Sample Data: echo "clientRequests#300#raw,$E
Regex Find: (,.*?,.*?,)
Replace Str: $1Unique
I want to find the 3rd comma so I can append to the name $_importExternalEmailData so the result is $_importExternalEmailDataU
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Great, thank you!!
Find:
Open in new window
Replace:Open in new window