in reply to multiple matches with a regex
Without knowing the details of your problem, I will offer a small example of how to extract integers from a scalar variable into an array using the /g modifier:
use strict; use warnings; use Data::Dumper; my $doc = 'hhh123 bbb 45 abc 999'; my @nums = $doc =~ /\d+/g; print Dumper(\@nums); __END__ $VAR1 = [ '123', '45', '999' ];
Update: Fixed typo in doc link, pointed out by davido.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: multiple matches with a regex
by davido (Cardinal) on Apr 11, 2009 at 07:22 UTC |