@a = $string =~/
( #capture matches and put them into @a
(?:\d+) | (?:"(?:.+?)")
)
/gx;
print Dumper \@a;
####
$VAR1 = [
'1',
'2',
'3',
'4',
'"fine"',
'"day"',
'"today"'
];
####
@b = $string =~/
(?: #don't capture matches
(\d+) | (?:"(.+?)")
#capture numbers and anything inside of quotes
)
/gx;
print Dumper \@b;
####
$VAR1 = [
'1',
undef,
'2',
undef,
'3',
undef,
'4',
undef,
undef,
'fine',
undef,
'day',
undef,
'today'
];
####
@c =
map {/.+/g} #if it's an undef, it's NOT getting into that array ;)
$string =~/
(?:
(\d+) | (?:"(.+?)")
)
/gx;
print Dumper \@c;
####
$VAR1 = [
'1',
'2',
'3',
'4',
'fine',
'day',
'today'
];