in reply to Comma-fy floats with (+/-)look(aheads/behinds)
Which will give the following result:while (<DATA>) { /\./ ? s/(?<=\d)(?=(\d{3})+(?:\.))/,/g : s/(?<=\d)(?=(\d{3})+(?!\d))/,/g; print "$_"; } __DATA__ 123 1234 12345 123446 1234567 +12345678.12 -123456789.12345678
Which is exactly what you wanted.123 1,234 12,345 123,446 1,234,567 +12,345,678.12 -123,456,789.12345678
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Comma-fy floats with (+/-)look(aheads/behinds)
by Anonymous Monk on Sep 22, 2003 at 13:24 UTC |