Hi! :)
I would like to format a number like 1500 into "1,500", for example. It should produce either "1,500,000" with 1500000. So I thought to use regular expressions and I met this eternal problem...
Admitting we are using the following expression to match and transform numbers:
^(\d{0,2})(\d{3})*$
With the following replacement:
$1,$2
Well, for numbers < 1M it is working. But, for numbers >= 1M it does not suffice. Does someone know if it is possible, and how, to identify the matching occurences of the pattern
(\d{3})* in my expression?
Indeed, the result for 1500000 will be "1,000" as the [u]last match</u> of the pattern will be the last three zeros. Finally, I don't want to capture these only ending zeros but all the repetitions of three-number groups in order to dump them separated with a comma.
NOTE: using regular expressions for this case is important to me since I should be able to implement some little stuff to format the numbers like I want to. I would like to learn more on this kind of capturing matters if someone could teach me.;)
Thank you!