dating commitment issues - Regular expression for validating numbers

regular expression for validating numbers-61

The expression for this can be quite complicated when you take into account fractional numbers, exponents, and more.

The previous section dealt primarily with validating strings; albeit, some of the strings were composed entirely of digits.

For simple numbers, that may be right, but when working with scientific or financial numbers, you often have to deal with positive and negative numbers, significant digits, exponents, and even different representations (like the comma used to separate thousands and millions).

Below are a few different formats of numbers that you might encounter.

A valid integer value should contain only digits and possibly a leading minus or plus sign.