PHP Regular Expression Validation Digital _php tutorial

Source: Internet
Author: User
PHP Tutorial Regular expression validation numbers

Non-negative floating-point number (positive floating point + 0): ^d+ (. d+)? $
Positive floating-point number ^ ([0-9]+.[ 0-9]*[1-9][0-9]*) | ([0-9]*[1-9][0-9]*. [0-9]+) | ([0-9]*[1-9][0-9]*)) $
Non-positive floating-point number (negative floating-point number + 0) ^ ((-d+ (. d+)?) | (0+ (. 0+)?)) $
Negative floating-point number ^ (-([0-9]+.[ 0-9]*[1-9][0-9]*) | ([0-9]*[1-9][0-9]*. [0-9]+) | ([0-9]*[1-9][0-9]*))) $
Floating point ^ (-?d+) (. d+)?


^[1-9]d*$

Match positive integers

^-[1-9]d*$

Match negative integers

^-? [1-9]d*$

Match integer

^[1-9]d*|0$

Match non-negative integers (positive integers + 0)

^-[1-9]d*|0$

Match a non-positive integer (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 numbers

^-? ([1-9]d*.d*|0.d*[1-9]d*|0?. 0+|0) $

Matching floating-point numbers

^[1-9]d*.d*|0.d*[1-9]d*|0?. 0+|0$

Match non-negative floating-point number (positive floating point + 0)

^ (-([1-9]d*.d*|0.d*[1-9]d*)) | 0+|0$

Match non-positive floating-point number (negative floating-point number + 0)


Verification Number: ^[0-9]*$
To verify N-bit numbers: ^d{n}$
Verify that at least n digits: ^d{n,}$
Verify the number of m-n bits: ^d{m,n}$
Verify numbers starting with 0 and non 0: ^ (0|[ 1-9][0-9]*) $
Verify that there is a positive real number with two decimal places: ^[0-9]+ (. [ 0-9]{2})? $
Verify that there is a positive real number with 1-3 decimal places: ^[0-9]+ (. [ 0-9]{1,3})? $
Verify non-zero positive integers: ^+? [1-9] [0-9]*$
To verify a nonzero negative integer: ^-[1-9][0-9]*$
Validates non-negative integers (positive integers + 0) ^d+$
Validates a non-positive integer (negative integer + 0) ^ ((-d+) | ( 0+)) $
Verify the character with a length of 3: ^. {3}$

?>


http://www.bkjia.com/PHPjc/445417.html www.bkjia.com true http://www.bkjia.com/PHPjc/445417.html techarticle PHP Tutorial Regular Expressions Validate numeric nonnegative floating point numbers (positive floating point + 0): ^d+ (. d+)? $ positive floating-point number ^ ([0-9]+.[ 0-9]*[1-9][0-9]*) | ([0-9]*[1-9][0-9]*. [0-9]+) | ([0-9]*[1-9][0-9]*)) $ non ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.