Of course! I forgot that braces are inherently range operators, so this should actually do the trick for me:
$max_lhs = $precision - $scale;
$max_rhs = $scale;
$float =~ m/
\A # beggining of string
\d{0,$max_lhs} # 0 to $max_lhs digits
\. # decimal point
\d{0,$max_rhs} # 0 to $max_rhs digits
\z # end of string
/xms;
I know the notion of what I'm calling 'precision' is confusing. I'm actually trying to check for the format of floats before inserting them into an Oracle number field and that's what Oracle calls them:
precision - total number of digits
scale - digits on the rhs
|