Small typo:

> +This regex from Benjamin Goldberg will added commas to numbers:

This regex from Benjamin Goldberg will also add commas to numbers:

Cheers,
Kevin

On Sat, Aug 17, 2002 at 03:38:03PM -0400, _brian_d_foy ([EMAIL PROTECTED]) said 
something similar to:
> * How can I output my numbers with commas added?
>    + a lot of people have asked me to un-delete  the original subroutine
>    + a couple of english fixes
> 
> 
> Index: perlfaq5.pod
> ===================================================================
> RCS file: /cvs/public/perlfaq/perlfaq5.pod,v
> retrieving revision 1.21
> diff -u -d -r1.21 perlfaq5.pod
> --- perlfaq5.pod        17 Jul 2002 17:51:36 -0000      1.21
> +++ perlfaq5.pod        17 Aug 2002 19:35:11 -0000
> @@ -288,11 +288,19 @@
>  
>  =head2 How can I output my numbers with commas added?
>  
> -This one from Benjamin Goldberg will do it for you:
> +This subroutine will add commas to your number:
> +
> +       sub commify {
> +          local $_  = shift;
> +          1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
> +          return $_;
> +          }
> +
> +This regex from Benjamin Goldberg will added commas to numbers:
>  
>     s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g;
>  
> -or written verbosely:
> +It is easier to see with comments:
>  
>     s/(
>         ^[-+]?            # beginning of number.

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"A surplus means there'll be money left over. Otherwise, it wouldn't be called
a surplus."
        -- G.W. Bush, Kalamazoo, MI 10/27/2000

Reply via email to