regex - What's a good regular expression for real numbers in Java? -


what's regular expression real numbers in java?

i created regex ([-]?[\\d]*\\.[\\d]*) , tested against following expected outputs:

in                  out        works? -------------------------------------- qwerty34.34abcd     34.34       yes qwe-34.34.34abcd    -34.34      no +17.-9abc           17.0        yes -.abc0              0.0         no 

i have out column(out). please provide regex passes of these tests.

try following:

((\+|-)?([0-9]+)(\.[0-9]+)?)|((\+|-)?\.?[0-9]+) 

this match real numbers, including integers, or without sign (and or without number before decimal point).


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -