Please note: On Sunday 16th May 00AM – 04AM CEST we will be performing planned maintenance on the RWS Community website. During this time you will not be able to access the website and post/reply. Apologies for the inconvenience.

Regex to find dollar amounts

Hi all!

I need help with a Regex to find currency amounts that may or may not include “US” or “US$” before them.

The source text is not always identified as a number, and it contains dots that I want to turn into commas (for example 1.000.000, which I want to convert to 1,000,000).

So far, I've been able to find the text I want, but haven't been able to get the replacement expression to do what I need.

Search string:

US\$(\d+)\.(\d+)\.(\d+)

Finds: US$4.123.950

Replace string:

US$\$1,$2,$3

Replaces with: US$\4,123,950

The result I want is US$4,123,950. If I delete the slash, it returns US$1,123,950. If I delete one of the dollar signs, it returns US4,123,950.

And I haven't even started tackling the part of including “US” or “US$” only if the source does.

Any ideas?

thanks so much!

Becky

Parents Reply Children