Just slightly modified the previous post:
use strict; while (defined(my $data = <DATA>)) { chomp $data; print "Got: ", $data, "\n"; if ($data =~ /[-+]?\d+| # optional sign followed by whole number or [-+]?\d{0,3} # optional sign followed by at most 3 digits (\.\d{1, 3})? # followed by decimal point, and finally by at mo +st 3 digits /x) { print "GOOD\n"; } else { print "BAD\n"; } } __DATA__ 12.12 123.123 0.1 1234.0 1234
In reply to Re: Need a regex..
by diddy_perl
in thread Need a regex..
by littlemonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |