http://www.perlmonks.org?node_id=983684

shortyfw06 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to modify the following regular expression, which is for integers either negative or positive.

$_[0] =~ /^(?:|-|\d+|-\d+)$/

I'd like the regular expression to also capture floating point values either negative or positive. I thought this would work but it is not.

$_[0] =~ /^(?:|-|\d+|-\d+|\d+\.\d+|-\d+\.\d+)$/