search and replace data with coma or dot

A place to try and solve your RegEx problems.
Post Reply
User avatar
michpatr

search and replace data with coma or dot

Post by michpatr »

Hi,

I would like to find the appropriate regex to search and replace in a source code of an html file :

- search simultaneously 12,50 and 12.50
- and replace it simultaneously respectively by (for instance) 12,80 and 12.80


Thank you in advance for any help.

Patrick
User avatar
Fool4UAnyway

Re: search and replace data with comma or dot

Post by Fool4UAnyway »

Find:
(\d+)([\.,])(\d+)

Replace by:
$1$280

Would that do?

Perhaps {$1}{$2}80.

You could also use "12[.,](\d+)" and "12$180" or the form that does work...
patrmich
Posts: 18
Joined: Fri Jul 01, 2011 9:01 am

Re: search and replace data with coma or dot

Post by patrmich »

Hi,

Thank you for the prompt reply.

I do not understand how (\d+)([\.,])(\d+) can search specifically for 12.50 and 12,50 ?

Thank you in advance,

Patrick
User avatar
Fool4UAnyway

Re: search and replace 12 50 with comma or dot

Post by Fool4UAnyway »

Specifically 12 50 with comma or dot = "12, then comma or dot, then 50".

Find:
12([\.,])50

Replace by:
12$180
patrmich
Posts: 18
Joined: Fri Jul 01, 2011 9:01 am

Re: search and replace data with coma or dot

Post by patrmich »

Thank you !

It does work well with Tewt Crawler
Post Reply