Home Download Buy Blog Forum Support

How to partialy replace a mached regex pattern?

How to partialy replace a mached regex pattern?

Postby attanze on Mon May 09, 2011 11:01 pm

I have a file with a lots of numbers like this: "10;23", "10;24" and also "some text;some text" and I want to replace only the ";" that are between number with ",". If I put into the "Find what:" field the regex: ;[0-9][0-9] is finding ";24" characters, but I dont know what I need to put into the "Replace with:" to replace ONLY the ";" character and not the numbers. If somebody knows how to do this, please answer.
attanze
 
Posts: 16
Joined: Sun May 01, 2011 8:30 pm

Re: How to partialy replace a mached regex pattern?

Postby Anomareh on Tue May 10, 2011 12:06 am

Just use captures. So for find: ";([0-9]{2})" and then replace: ",$1".
Anomareh
 
Posts: 222
Joined: Thu Oct 01, 2009 7:32 pm

Re: How to partialy replace a mached regex pattern?

Postby adzenith on Tue May 10, 2011 4:15 pm

You can also use positive lookahead assertions: http://www.regular-expressions.info/lookaround.html
adzenith
 
Posts: 1216
Joined: Mon Oct 19, 2009 9:12 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 20 guests