blackadder has asked for the wisdom of the Perl Monks concerning the following question:
And I only want to capture the numbers in the string. i.eCFD123_TRE_MXD TRD981_GHD_MXW . . .
I tried this code:123 981
By which i mean; scan from left to right, from the begining of the string, ignore multiple alphabetical chars, grab multiple digits, save it to memory. However it doesn't seem to work($var) =~ /^[^a-z]+([0-9]+)/; print "$1\n";
it returned the right values, but still wondering if there is a better way for doing this - without destroying the original string?$var =~ s/([0-9]+)//g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with regEX
by japhy (Canon) on Sep 14, 2005 at 13:20 UTC | |
|
Re: Help with regEX
by davidrw (Prior) on Sep 14, 2005 at 13:24 UTC | |
|
Re: Help with regEX
by reneeb (Chaplain) on Sep 14, 2005 at 13:18 UTC | |
|
Re: Help with regEX
by Codon (Friar) on Sep 14, 2005 at 16:57 UTC |