Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm attempting to extract numbers from codes in this generalised format (always begin with MD:Z: but what follows is variable):
MD:Z:4C3C7C0T2^T9C44Desired output (separate array elements):
4 3 7 0 2 9 44
As I need to maintain positional information and length of each number (i.e. it must be clear that 44 = 44 and not the product of something like 4T4 after screening out letters) i've tried to use split:
my @test = split((/\D/g), $input);To split on any non-number; however this returns a set of leading empty array values arising from the consecutive matches on 'MD:Z:'. Is there a way to suppress these or a better way to go about getting the desired result?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Leading empty array elements after splitting
by Athanasius (Archbishop) on Aug 22, 2016 at 15:26 UTC | |
by Anonymous Monk on Aug 22, 2016 at 16:20 UTC | |
by stevieb (Canon) on Aug 22, 2016 at 16:29 UTC | |
by Anonymous Monk on Aug 22, 2016 at 16:32 UTC | |
by stevieb (Canon) on Aug 22, 2016 at 17:00 UTC | |
| |
|
Re: Leading empty array elements after splitting
by stevieb (Canon) on Aug 22, 2016 at 15:27 UTC | |
|
Re: Leading empty array elements after splitting
by TomDLux (Vicar) on Aug 23, 2016 at 16:01 UTC |