in reply to Re^2: regex to capture an unsigned decimal value, but also preserve the user's formatting.
in thread regex to capture an unsigned decimal value, but also preserving the user's formatting.
Correct on both counts: (1) The dot should have been backslashed. (Edit: I've fixed the backslashing of .) (2) This works only for strings that don't contain dots anywhere to the left of the target "number". :). I didn't see any in his sample input, but the possibility supports the notion of "You have a problem. You think 'I will solve it with a regular expression.' Now you have two problems."
A better solution would probably leverage Regexp::Common, or the regular expressions revealed in perlfaq4 under "How do I determine whether a scalar is a number/whole/integer/float?"
Dave
|
|---|