If you want something similar to a C float, here's how to tickle Perl from a regular expression that does this using Regexp :: Common module from CPAN :
$ perl -MRegexp::Common -le 'print $RE{num}{real}' (?:(?i)(?:[+-]?)(?:(?=[.]?[0123456789])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))
You can tweak this a bit if you want, but it gives you the basic idea.
In fact, it is remarkably flexible. For example, this spills out a pattern for real base-2 numbers, allowing commas every three places:
$ perl -MRegexp::Common -le 'print $RE{num}{real}{-base => 2}{-sep => ","}{-group => 3}' (?:(?i)(?:[+-]?)(?:(?=[.]?[01])(?:[01]{1,3}(?:(?:[,])[01]{3})*)(?:(?:[.])(?:[01]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[01]+))|))
The documentation shows that the full possible syntax for the numeric patterns that it can spit out for you is:
$RE{num}{int}{-base}{-sep}{-group}{-places} $RE{num}{real}{-base}{-radix}{-places}{-sep}{-group}{-expon} $RE{num}{dec}{-radix}{-places}{-sep}{-group}{-expon} $RE{num}{oct}{-radix}{-places}{-sep}{-group}{-expon} $RE{num}{bin}{-radix}{-places}{-sep}{-group}{-expon} $RE{num}{hex}{-radix}{-places}{-sep}{-group}{-expon} $RE{num}{decimal}{-base}{-radix}{-places}{-sep}{-group} $RE{num}{square} $RE{num}{roman}
Do it really to tune it to whatever you want. And yes, of course, you can use these patterns in Java.
Enjoy.
source share