in reply to Regex for max length float
how do I look for n or less characters?
You want /\d{0,3}/ (three digits or less)?
$x = '1234'; print $x =~ /^\d{0,3}$/ ? "'$x' matches\n" : "'$x' no match\n"; $x = '123'; print $x =~ /^\d{0,3}$/ ? "'$x' matches\n" : "'$x' no match\n"; $x = '12'; print $x =~ /^\d{0,3}$/ ? "'$x' matches\n" : "'$x' no match\n"; $x = '1'; print $x =~ /^\d{0,3}$/ ? "'$x' matches\n" : "'$x' no match\n"; $x = ''; print $x =~ /^\d{0,3}$/ ? "'$x' matches\n" : "'$x' no match\n"; __END__ '1234' no match '123' matches '12' matches '1' matches '' matches
I wonder if Regexp::Common::number would help you.
|
|---|