in reply to Re: number of numbers in a string
in thread number of numbers in a string

# or: ++$count while $foo =~ /\d/g; # or: $count = $foo =~ s/(\d)/$1/g; # or: $count = () = $foo =~ /\d/g; # or: $foo =~ s/(\d)/++$count; $1/ge; # etc.
But y/// (aka tr///) is the perfect-fit tool for this job.

Update: s/gee/ge/; thanks, japhy; yes, a typo

Replies are listed 'Best First'.
Re^3: number of numbers in a string
by japhy (Canon) on Aug 12, 2004 at 18:33 UTC
    You have an extra /e modifier on your last regex, but it ends up being harmless. But it's still extraneous; while it might be a typo, it might also be a sign of a misunderstanding of its purpose.
    _____________________________________________________
    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart