Home  >  Article  >  Backend Development  >  PHP regular expression: match specific numbers_PHP Tutorial

PHP regular expression: match specific numbers_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:492020browse

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)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486175.htmlTechArticlePHP 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*|...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn