Page 1 of 1

Regex to replace hyphens between two numbers with commas

Posted: Thu Dec 22, 2016 2:25 pm
by bee123
Hi there,

I have a text with numbers in between, the numbers should change from 9-3 into something like 9,3.
I can find the numbers with \d{1,2}[\*\-]{1}\d{1,2}
but how do I do the replacement?

Thanks for your help!

Re: Regex to replace hyphens between two numbers with commas

Posted: Thu Dec 22, 2016 2:36 pm
by Radu
Hi,

You need to create groups using ( and ) for the text which will stay in place and then in the replace field use $1, $2, etc for the groups you want to keep.
So if you search for (\d{1,2})[\*\-]{1}(\d{1,2}) you can replace with $1,$2.

Regards,
Radu

Re: Regex to replace hyphens between two numbers with commas

Posted: Thu Dec 22, 2016 2:40 pm
by bee123
Thank you!