9 characters long? Does 1.3456789 count? Or do you really mean 5 digits after the decimal place only? I'm assuming the latter. And that the - sign doesn't count.
/^-?(\d{1,3}(?:\.\d{1,5})?)$/
That is, an optional leading - sign, followed by 1 to 3 digits (to allow for 180 degrees East/West), followed, optionally, by a dot, and then 1 to 5 more digits.
Better yet, try:
use Regexp::Common;
/^$RE{num}{decimal}{-places=>'0,5'}$/ and $_ <= 180;
No sense reinventing the wheel. :-) | [reply] [d/l] [select] |