Numbers only (or digits only) regular expressions can be used to validate if a string contains only numbers.
Below is a simple regular expression that allows validating if a given string contains only numbers:
True
False
Enter a text in the input above to see the result
Example code in Javascript:
Real number regex can be used to validate or exact real numbers from a string.
True
False
Enter a text in the input above to see the result
Example code in Javascript:
True
False
Enter a text in the input above to see the result
In JavaScript you can also validate number by trying to parse it using a Number constructor and then using isNaN function of a Number class:
Discover UI Bakery – an intuitive visual internal tools builder.