in reply to number of numbers in a string
Looking at merlyn's Forcing list context, the above can be simplified as:$foo = "spider9832man23"; my @digits = ($foo =~ /\d/g); print scalar(@digits); # print 6
$foo = "spider9832man23"; print ( $count = () = $foo =~ /\d/g); # prints: 6
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: number of numbers in a string
by ysth (Canon) on Aug 12, 2004 at 18:16 UTC | |
by japhy (Canon) on Aug 12, 2004 at 18:33 UTC |