regular expression for finding decimal/float numbers?

MBehtemam picture MBehtemam · Apr 21, 2012 · Viewed 61k times · Source

i need a regular expression for decimal/float numbers like 12 12.2 1236.32 123.333 and +12.00 or -12.00 or ...123.123... for using in javascript and jQuery. Thank you.

Answer

Paul picture Paul · Apr 21, 2012

Optionally match a + or - at the beginning, followed by one or more decimal digits, optional followed by a decimal point and one or more decimal digits util the end of the string:

/^[+-]?\d+(\.\d+)?$/

RegexPal