Detailed two PHP regular expression special characters _php tutorial

Source: Internet
Author: User
Tags php regular expression uppercase letter
PHP Regular Expression special characters "[]" and "", then what are they? What is the specific operation? They are special characters, so what is the special place in the use process? Let's take a look at the specific introduction.

There are also two very important special characters that are "[]". They can match the characters that appear in "[]", such as "/[az]/" can match a single character "a" or "Z", if the above expression is changed to such "/[a-z]/", you can match any single lowercase letter, such as "A", "B" and so on.

About PHP Regular expression special characters "[]":

If "^" appears in "[]", it means that this expression does not match the characters appearing in "[]", such as "/[^a-z]/" does not match any lowercase letters! And the regular expression gives the default values of several "[]":

[:alpha:]: Matches any letter

[:alnum:]: Matches any letter and number

[:d Igit:]: Matches any number

[:space:]: Match whitespace

[:upper:]: matches any uppercase letter

[:lower:]: matches any lowercase letter

[:p UNCT:]: matches any punctuation

[:xdigit:]: Matches any 16 binary digits

About PHP Regular expression special characters "":

The following special characters are represented by the escape symbol "" after escaping the following meanings:

S: matches individual whitespace

S: Used to match all characters except a single space character.

D: Used to match numbers from 0 to 9, equivalent to "/[0-9]/".

W: Used to match letters, numbers, or underscore characters, equivalent to "/[a-za-z0-9_]/".

W: used to match all characters that do not match W, equivalent to "/[^a-za-z0-9_]/".

D: Used to match any numeric characters that are not 10 binary.

.: Used to match all characters except the newline character, if the modifier "s" is decorated, "." can represent any character.

Introduction to the special characters of the PHP regular expression is introduced to you here, I hope that it is helpful to you to understand and master the use of PHP regular expression special characters.


http://www.bkjia.com/PHPjc/446588.html www.bkjia.com true http://www.bkjia.com/PHPjc/446588.html techarticle PHP Regular Expression special characters "[]" and "", then what are they? What is the specific operation? They are special characters, so what is the special place in the use process ...

  • 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.