P is for Practical | |
PerlMonks |
Re: How do I print a large integer with thousands separators?by stefp (Vicar) |
on Oct 10, 2001 at 05:18 UTC ( [id://117909]=note: print w/replies, xml ) | Need Help?? |
The lookahead (?=(\d{3})+$) ensures that the number of digits before each underscore we insert is a multiple of 3. An extra set of parentheses fools Perl because the regex parser barks when there are two quantifiers in a row, which is perfectly legitimate here. This issue was also discussed in the thread Splitting every 3 digits?.
In Section
Seekers of Perl Wisdom
|
|