Содержание
Numbers only regex (digits only) PHP
Numbers only (or digits only) regular expressions can be used to validate if a string contains only numbers.
Basic numbers only regex
Below is a simple regular expression that allows validating if a given string contains only numbers:
Enter a text in the input above to see the result
Real number regex
Real number regex can be used to validate or exact real numbers from a string.
Enter a text in the input above to see the result
Enter a text in the input above to see the result
Notes on number only regex validation
In PHP you can also validate number by using is_numeric function:
Create an internal tool with UI Bakery
Discover UI Bakery – an intuitive visual internal tools builder.