But y/// (aka tr///) is the perfect-fit tool for this job.# 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.
Update: s/gee/ge/; thanks, japhy; yes, a typo
In reply to Re^2: number of numbers in a string
by ysth
in thread number of numbers in a string
by concept03
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |