in reply to Extraction of numbers in an string
You could split into pairs on a '<' or a '>' optionally followed by ':<' then split the pairs on a comma.
johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -E ' my $str = q{<1,2>:<5,7>:<3,0>}; my @nos = map { split m{,} } split m{(?x) < | > (?: :< )?}, $str; say for @nos;' 1 2 5 7 3 0
I hope this is helpful.
Update: Changed quantifier from * to ?.
Cheers,
JohnGG
|
|---|