Home > Article > Backend Development > PHP regular expression: match specific numbers_PHP Tutorial
PHP regular expression: matching specific numbers, commonly used introduction, I hope it will be useful to everyone.
^[1-9]d*$ // Match positive integers
^-[1-9]d*$ // Match negative integers
^-?[1-9]d*$ / /Match integers
^[1-9]d*|0$ //Match non-negative integers (positive integers 0)
^-[1-9]d*|0$ //Match non-positive integers ( Negative integer 0)
^[1-9]d*.d*|0.d*[1-9]d*$ //Match positive floating point number
^-([1-9]d* .d*|0.d*[1-9]d*)$ //Match negative floating point number
^-?([1-9]d*.d*|0.d*[1-9] d*|0?.0 |0)$ //Match floating point number
^[1-9]d*.d*|0.d*[1-9]d*|0?.0 |0$ //Match non-negative floating point numbers (positive floating point numbers 0)
^(-([1-9]d*.d*|0.d*[1-9]d*))|0?.0 | 0$ //Match non-positive floating point numbers (negative floating point numbers 0)