/^-?(?:\d+|\d*\.\d+)$/
This matches normal floats e.g. 3.14
, shorthands for decimal part only e.g. .5
and integers e.g. 9
as well as negative numbers.
More Related Contents:
- PHP validation/regex for URL
- PHP regular expressions: No ending delimiter ‘^’ found in
- Replace URLs in text with HTML links
- Remove non-utf8 characters from string
- How to remove accents and turn letters into “plain” ASCII characters? [duplicate]
- remove script tag from HTML content
- Regexp to add attribute in any xml tags
- PHP remove special character from string
- preg_replace: add number after backreference
- Retrieve all hashtags from a tweet in a PHP function
- How do I remove blank lines from text in PHP?
- How to use RegexIterator in PHP
- Regular expressions for a range of unicode points PHP
- How to write a recursive regex that matches nested parentheses?
- Split alphanumeric string between leading digits and trailing letters
- Allow only [a-z][A-Z][0-9] in string using PHP
- non-breaking utf-8 0xc2a0 space and preg_replace strange behaviour
- What literal characters should be escaped in a regex?
- Warning: preg_replace(): Unknown modifier ‘g’
- Validating US phone number with php/regex
- php regex [b] to
- Regex to strip comments and multi-line comments and empty lines
- RegExp in preg_match function returning browser error
- Regex for password PHP [duplicate]
- regular expression and forward slash
- How to validate phone number using PHP? [duplicate]
- What does [\S\s]* mean in regex in PHP?
- UTF-8 in PHP regular expressions [duplicate]
- Get non-numeric characters then number on each line of a block of texf
- Validate date format in php