Bourgneuf Francois wrote:
>
> This version works with decimals :
> DB<1> $_=1234567.7891;
>
> DB<2> s/\B(?=(...)*\.)/ /g
>
> DB<3> print;
> 1 234 567.7891
> Bour9
>
> -----Message d'origine-----
> De : Terje Kristensen [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 29 août 2006 07:40
> À : 'Fun with Perl'
> Objet : SV: Super regexp to format numbers
>
> Here's the golfed version :) ( borrowed from Rick Klements solution to
> the TPR(0,5b) contest ).
>
> s/\B(?=(...)*$)/ /g
>
> Terje K
>
> p.s. This works on integers only.
And this version works with or without decimals:
s/(\..*)|\B(?=(\d{3})*\b)/$1 || " "/ge
--
Rick Klement