Simple question for the regEXperts out there...
I have a string that is always in the format: aaaaa.nn+x.y
a is always 5 chars
n can be 1 or 2 digits
x can be +/- (with sign), 1-4 digits
y is always positive (no sign), 1-4 digits
Some examples:
A123C.11+002.001
FC32G.2-1.0
12B15.01+2145.15
I need all 4 pieces and the length of x & y. The following works:
my $id= "A123C.11+002.001";
my @tmp = split(/[\.+-]/,$id);
my $part = $tmp[0];
my $unit = $tmp[1];
my $x = $tmp[2];
my $y = $tmp[3];
my $xlen = length $tmp[2];
my $ylen = length $tmp[3];
but in my quest for understanding regex, I'm always looking for more elegant
(obfuscated :-) code...
Anybody have a good one-liner for this?
my ($part,$unit,$x,$y,$xlen,$ylen) = /* Some obfuscated code here.. */
Thanks!
-Dan
---
[email protected]
(To reply via email, remove 'reverse(nospam)' in address. Spambots are
getting waaaay too smart nowadays...:-)
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/