Php regular expression verification number_php tutorial-PHP Tutorial

Source: Internet
Author: User
Php regular expression to verify numbers. Php Tutorial regular expression verification number non-negative floating point number (positive floating point number + 0): ^ d + (. d + )? $ Positive floating point ^ ([0-9] +. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] *. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ regular expression verification numbers in non-php Tutorial

Non-negative floating point number (positive floating point number + 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 number ^ (-? D +) (. d + )?


^ [1-9] d * $

// Match a positive integer

^-[1-9] d * $

// Match a negative integer

^ -? [1-9] d * $

// Match the integer

^ [1-9] d * | 0 $

// Match a non-negative integer (positive integer + 0)

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

// Match non-positive integers (negative integers + 0)

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

// Match the positive floating point number

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

// Match the negative floating point number

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

// Match floating point numbers

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

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

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

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


Verification Number: ^ [0-9] * $
Verify the n-digit number: ^ d {n} $
Verify the number of at least n digits: ^ d {n,} $
Verify m-n digits: ^ d {m, n} $
Verify the number starting with zero or zero: ^ (0 | [1-9] [0-9] *) $
Verify the positive number of two decimal places: ^ [0-9] + (. [0-9] {2 })? $
Verify the positive number of 1-3 decimal places: ^ [0-9] + (. [0-9] {1, 3 })? $
Verify a non-zero positive integer: ^ +? [1-9] [0-9] * $
Verify a non-zero negative integer: ^-[1-9] [0-9] * $
Verify non-negative integer (positive integer + 0) ^ d + $
Verify non-positive integer (negative integer + 0) ^ (-d +) | (0 +) $
3 characters for verification: ^. {3} $

?>


Regularizedregular expression verifies the number non-negative floating point number (positive floating point number + 0): ^ d + (. d + )? $ Positive floating point ^ ([0-9] +. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] *. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ not...

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.