use Regexp::Common; $has_dollar_sign = $str =~ s/^([-+]?)\$/$1/; if ($str =~ /^$RE{num}{decimal}{-sep => ','}{-keep}$/) { $is_numeric = 1; $sign = $2; $has_decimal_point = $5 ? 1 : 0; $has_commas = $str =~ /,/ }