J
Joe Cosby
I have a string which will always contain a letter followed by
numbers, eg "x12345"
I want to take the numbers and put them in another variable.
So I do this:
$test = "x12345";
$_ = $test;
m/(\d+)/;
$justTheNumbers = $1;
print "justTheNumbers is $justTheNumbers\n";
and that works, $justTheNumbers is "12345", which is what I want.
The three-line way I do it seems retarded to me though. Is there a
simpler way to do it?
I mean, something that would occur more or less naturally to somebody
more familiar with Perl and Regex? I suppose there's always some
simpler way to do anything ... it seems like I must be missing
something obvious though.
--
Joe Cosby
http://joecosby.com/
YOU can be more like "Bob" than you are now!
http://www.subgenius.com
numbers, eg "x12345"
I want to take the numbers and put them in another variable.
So I do this:
$test = "x12345";
$_ = $test;
m/(\d+)/;
$justTheNumbers = $1;
print "justTheNumbers is $justTheNumbers\n";
and that works, $justTheNumbers is "12345", which is what I want.
The three-line way I do it seems retarded to me though. Is there a
simpler way to do it?
I mean, something that would occur more or less naturally to somebody
more familiar with Perl and Regex? I suppose there's always some
simpler way to do anything ... it seems like I must be missing
something obvious though.
--
Joe Cosby
http://joecosby.com/
YOU can be more like "Bob" than you are now!
http://www.subgenius.com