Regular expression System tutorial (V) _php Tutorial

Source: Internet
Author: User
5. All symbols explained

<>< p="">

http://www.bkjia.com/PHPjc/532537.html www.bkjia.com true http://www.bkjia.com/PHPjc/532537.html techarticle 5. Full symbol explanation character description marks the next character as a special character, or a literal character, or a backward reference, or an octal escape character. For example, n matches the word ...

  • <>
    character Description
    Marks the next character as a special character, or a literal character, or a backward reference, or an octal escape. For example, n matches the character "n". Matches a line break. Sequence \ Match "" and "(" Then Match "(".
    ^ Matches the starting position of the input string. If the Multiline property of the RegExp object is set, ^ also matches or follows the position.
    $ Matches the end position of the input string. If the Multiline property of the RegExp object is set, $ also matches or precedes the position.
    * Matches the preceding subexpression 0 or more times. For example, zo* can match "z" and "Zoo". * Equivalent to {0,}.
    + Matches the preceding subexpression one or more times. For example, zo+ can match "Zo" and "Zoo", but not "Z". + equivalent to {1,}.
    ? Matches the preceding subexpression 0 or one time. For example, "Do (es)?" can match "do" in "do" or "does".? Equivalent to {0,1}.
    N N is a non-negative integer. Matches the determined n times. For example, o{2} cannot match o in "Bob", but can match two o in "food".
    {N,} N is a non-negative integer. Match at least n times. For example, o{2,} cannot match o in "Bob", but can match all o in "Foooood". O{1,} is equivalent to o+. O{0,} is equivalent to o*.
    {N,m} Both M and n are non-negative integers, where n <= m. Matches at least n times and matches up to M times. For example, "o{1,3}" will match the first three o in "Fooooood". o{0,1} is equivalent to O?. Note that there can be no spaces between a comma and two numbers.
    ? When the character immediately follows any other restriction (*, +,?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. The non-greedy pattern matches the searched string as little as possible, while the default greedy pattern matches as many of the searched strings as possible. For example, for the string "Oooo", o+? A single "O" will be matched, and o+ will match all O.
    . Matches any single character except "". To match any characters that are included, use a pattern like [.].
    (pattern) Match pattern and get this match. The obtained matches can be obtained from the resulting Matches collection, the Submatches collection is used in VBScript, and the $0...$9 property is used in JScript. To match the parentheses character, use (or).
    (?:p Attern) Matches pattern but does not get a matching result, which means that this is a non-fetch match and is not stored for later use. This is useful when using the "or" character (|) to combine parts of a pattern. For example, Industr (?: y|ies) is a more abbreviated expression than industry|industries.
    (? =pattern) Forward-checking matches the lookup string at the beginning of any string that matches the pattern. This is a non-fetch match, which means that the match does not need to be acquired for later use. For example, Windows (? =95|98| nt|2000) can match windows in Windows 2000, but it does not match Windows 3.1. Pre-checking does not consume characters, that is, after a match occurs, the next matching search starts immediately after the last match, rather than starting with the character that contains the pre-check.
    (?! Pattern A negative pre-check matches the lookup string at the beginning of any string that does not match the pattern. This is a non-fetch match, which means that the match does not need to be acquired for later use. For example, Windows (?! 95|98| nt|2000) can match windows in Windows 3.1, but it does not match Windows 2000. Pre-check does not consume characters, that is, after a match occurs, the next matching search starts immediately after the last match, rather than starting with the character that contains the pre-check
    X|y Match x or Y. For example, Z|food can match "z" or "food". (z|f) Ood matches "Zood" or "food".
    [XYZ] The character set is combined. Matches any one of the characters contained. For example, [ABC] can match a in "plain".
    [^XYZ] Negative character set. Matches any character that is not contained. For example, [^ABC] can match p in "plain".
    [A-z] The character range. Matches any character within the specified range. For example, [A-z] can match any lowercase alphabetic character in the range A to Z.
    [^a-z] A negative character range. Matches any character that is not in the specified range. For example, [^a-z] can match any character that is not within the range of A to Z.
    Matches a word boundary, which is the position between a word and a space. For example, er can match the ER in "never", but not the ER in "verb".
    B Matches a non-word boundary. The ErB can match the ER in "verb", but not the ER in "never".
    Cx Matches the control character indicated by X. For example, CM matches a control-m or carriage return character. The value of x must be one of a-Z or a-Z. Otherwise, c is treated as a literal C character.
    D Matches a numeric character. equivalent to [0-9].
    D Matches a non-numeric character. equivalent to [^0-9].
    F Matches a page break. Equivalent to x0c and CL.
    Matches a line break. Equivalent to x0a and CJ.
    Matches a carriage return character. Equivalent to x0d and CM.
    S Matches any whitespace character, including spaces, tabs, page breaks, and so on. equivalent to [FV].
    S Matches any non-whitespace character. equivalent to [^ FV].
    Matches a tab character. Equivalent to x09 and CI.
    V Matches a vertical tab. Equivalent to x0b and CK.
    W Matches any word character that includes an underscore. equivalent to [a-za-z0-9_].
    W Matches any non-word character. equivalent to [^a-za-z0-9_].
    Xn Match N, where n is the hexadecimal escape value. The hexadecimal escape value must be two digits long for a determination. For example, x41 matches "A". x041 is equivalent to x04 & "1". ASCII encoding can be used in regular expressions:
    Um

    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.