for ( $number ) { /\./ ? s/(?<=\d)(?=(\d{3})+(?:\.))/,/g : s/(?<=\d)(?=(\d{3})+(?!\d))/,/g; }
This says if the number has a decimal point, end there for the purposes of commafication. Otherwise, go to the end of the string.
In reply to Re: How do I print a large integer with thousands separators?
by Roger
in thread How do I print a large integer with thousands separators?
by miblo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |