Replace second + with _

A swapping-ground for Regular Expression syntax

Replace second + with _

Postby MightyMrMatt » Fri Jan 18, 2019 5:45 am

I have about 600K files with the following naming scheme:

someFile+1010101+1.jpg

I need to change the second plus sign to an underscore. I've tried this:

Match: (.*?)+(.*?)+(.*)
Replace: \1+\2_\3

But it doesn't show any change. What am I missing?
MightyMrMatt
 
Posts: 2
Joined: Fri Jan 18, 2019 5:34 am

Re: Replace second + with _

Postby Admin » Fri Jan 18, 2019 6:21 am

Because + means "match 1 or more times" in regex , you will need to take it literally by prefixing with \
You also do not need ?

Match: (.*)\+(.*)\+(.*)
Replace: \1+\2_\3
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm

Re: Replace second + with _

Postby MightyMrMatt » Fri Jan 18, 2019 11:07 am

That's it! Thanks for the help!
MightyMrMatt
 
Posts: 2
Joined: Fri Jan 18, 2019 5:34 am


Return to Regular Expressions