
Cupidvogel
Novice
Mar 30, 2012, 5:43 AM
Post #1 of 3
(586 views)
|
|
Problem with Regular Expression
|
Can't Post
|
|
Hi, I am trying this code:
$a = "12."; $a =~ /^\d*(\.\d{1,5})?/; print $&; Clearly the ? quantifier at the end of (\.\d{1,5}) ensures that for the pattern to match, a decimal point, if there, has to be followed by at least 1 digit, right? But on trying out with an input of 12.0, I am getting 12 as output. How come? The \d* matches 12 alright, but then because there is no digit following the decimal, shouldn't the match fail?
|