in reply to Re: Extraction of numbers in an string
in thread Extraction of numbers in an string
This has a problem with the multi-digit requirement t-rex revealed to us here, and unfortunately there's no simple way to fix it by the use of \d+ or any other trick I can think of:
c:\@Work\Perl\monks>perl -wMstrict -le "printf qq{$_ } for grep {/\d/} split '', q(<1,22>:<5,7>:<333,0>); " 1 2 2 5 7 3 3 3 0
Update: Actually, if one were married to split, it could be made to work with a rather more complex regex:
But I wouldn't recommend it.c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @d = grep length, split qr{ >:< | [<,>] }xms, q(<1,22>:<5,7>:<333, +0>); dd @d; " (1, 22, 5, 7, 333, 0)
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Extraction of numbers in an string
by tybalt89 (Monsignor) on Nov 25, 2016 at 19:54 UTC | |
by Not_a_Number (Prior) on Nov 25, 2016 at 20:20 UTC | |
by tybalt89 (Monsignor) on Nov 25, 2016 at 20:47 UTC | |
by AnomalousMonk (Archbishop) on Nov 25, 2016 at 20:50 UTC | |
by AnomalousMonk (Archbishop) on Nov 25, 2016 at 20:52 UTC | |
|
Re^3: Extraction of numbers in an string
by karlgoethebier (Abbot) on Nov 26, 2016 at 10:08 UTC |