Search code examples
javascriptregexfloating-pointdecimal

regular expression for finding decimal/float numbers?


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.


Solution

  • 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