I only realized that it incorrectly commifies decimal numbers after lying in bed for a few minutes, and I was too tired to get up and enhance it to fix the problem... :-)
Try the following:
$number =~ s/((?:\A[+-]?|\G)\d+?)(?=(?:\d{3})+(?:\.|\z))/$1,/g;
Proof that RE's can be fun...
In reply to Re: "Commifying" a number
by MarkM
in thread "Commifying" a number
by Tanalis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |