Special characters in regular expressions:
Character / Significance: For characters, it is usually represented by literal meaning, indicating that the following characters are special characters, not explaining. For example: / b / match character 'b', by adding a backslash in front of B, that is, / b /, then the character turns into a special character, indicating the boundary of the matching of a word. Or: For a few characters, it is usually noted that it is special, indicating that the following characters are not special, but should be explained by literal. For example: * is a special character, matching any means (including 0 characters); for example: / a * / means matches 0 or more A. In order to match the literal *, a backslash is added in front of a; for example: / a * / match 'a *'. Character ^ Significance: The matching character must be at the forefront. For example: / ^ A / does not match 'A' in "AN A,", but matches the most in front of "AN A.". Character $ Significance: Similar to ^, match the last character. For example: / t $ / does not match 'T' in "Eater", but match 't' in "EAT". Character * Significance: Match * The character is 0 times or N times. For example: / bo * / match 'boooo' or "A Bird Warbled" in "a ghost boooed", but does not match any of the characters in "Agoat G Runted". Character Significance: Match the character in front of the number once or N times. Equivalent to {1,}. For example: / a / match All 'A' in 'A' in "Candy". "All 'A'. Character? Significance: Match? The character is 0 times or 1 time. For example: / e? Le? / Match 'el' and "Angle." In "Angel". Character. Significance: (decis) matches all single characters except the linefinder. For example: /. N / match 'an' and 'on' in "NAY, An Apple IS on The Tree", but do not match 'NAY'. Character (X) Significance: Match 'X' and logs the matching value. For example: / (foo) / match and record "Foo Bar." In 'foo'. Matching substrings can be returned from the results of the result array [1], ..., [n], or by the regexp object, ..., return. Character X│Y Significance: Match 'x' or 'Y'. For example: / Green│RED / The 'Red' in 'Green' in "Green Apple" is matched. Character {n} meaning: The N here is a positive integer. Match the N characters in front. For example: / a {2} / does not match 'a' in "Candy,", but matches all of 'A' and "Caaandy." In "Caandy". ". Character {n,} Significance: The N is a positive integer. Match at least n front characters. For example: / a {2,} does not match 'a' in "Candy", but matches all 'A' characters in "Caandy" all 'A' characters {n, m} meaning: here N and M are all positive integers. Match at least n up to M phed characters.
For example: / a {1, 3} / does not match any character in "cndy", but matches "Caandy," in "Caandy," in front of "Caandy," in front of "CaaaaaaaAandy" in front Three 'a', pay attention: There are many 'a' in "CaaaaaAndy", but only match the three 'A' "AAA" in front. Character [XYZ] Significance: A list of characters, matching any of the characters listed. You can use even characters - pointing out a range of characters. For example: [ABCD] is the same as [A-C]. They match 'c' in 'B' and "Ache" in "Brisket". Character [^ xyz] Significance: A character is replenished, that is, it matches everything except the listed characters. You can use a hyphen - pointing out a range of characters. For example: [^ ABC] and [^ a-C] equivalence, they first match 'h' in 'r' and "chop." In "BRISKET". Character Significance: Match a space (do not confuse with B) Character B Significance: Match a word line, such as a space (do not confuse), for example: / bnw / match 'NO', / WYB / Match in "Noonday" 'ly' in "POSSIBLY YesterDay.". Character B Significance: Match a non-bound line of a word, for example: / WBN / Match 'on', / ybw / match "Possibly Yesterday." In "Possibly YesterDay." In "Noonday". Character CX Significance: The X here is a control character. Match a control character of a string. For example: / cm / matches Control-m in a string. Character D Significance: Match a number, equivalent to [0-9]. For example: / d / or / [0-9] / match '2' in "B2 IS the suite number.". Character D Significance: Match any non-figures, equivalent to [^ 0-9]. For example: / d / or / [^ 0-9] / match "B2 is the suite number." In 'b'. Character F Signature: Matching a Table Character N Signature: Matching a Lingerie Character R Sign: Matching a Cargoat Character S: Matching a single White space character, including space, Tab, Form feed, wrap, equivalent [FNRTV]. For example: / sw * / match 'Bar' in "Foo Bar.". Character s Significance: Match a single character other than WHITE spaces, equivalent to [^ Fnrtv]. For example: / s / w * Match "Foo Bar." In 'foo'. Character T Size: Match a tabby character v meaning: match a head tab character w Significance: match all numbers and letters and underscore, equivalent to [A-ZA-Z0-9_]. For example: / W / Match '3' in 'A', ". 28," in "Apple," in '3' in '3'. Character W Significance: Match other characters except numbers, letters and underscore, equivalent to [^ A-ZA-ZA-Z0-9_]. For example: / w / or / [^ $ A-ZA-Z0-9 _] / match "50%." In '%'. Character n Significance: The N here is a positive integer.
Match the value of the N of the last substring of a regular expression (count left brackets). For example: / apple, orange 'in the "Apple, Orange, Cherry, Peach." There is a more complete example below. Note: If the number in the left wrapping brackets is smaller than the number specified, n is removed as a description of the octal ESCAPE. Character OOctal and Xhex Significance: OOctal here is an octa-based Escape value, and Xhex is a hexadecimal ESCAPE value that allows embedding ASCII code in a regular expression: The following table is a metamorphic character and its in regular expression. A complete list of behaviors in the context:
Character Description / Tags the next character as a special character, or a primary character, or a backward reference, or an octave. For example, 'n' matches characters "n". '/ n' matches a newline. Sequence '/' Match "" and "/ (" match "(". ^ Matches the start position of the input string. If the demiline property of the regexp object is set, ^ also matches '/ n' or '/ r' after Location. $ Match the end position of the input string. If the multiline property of the regexp object is set, $ also matches the position before '/ n' or '/ r'. * Match the previous sub-expression zero or multiple times. For example, ZO * can match "Z" and "ZOO". * Equivalent to {0,}. Match the previous sub-expression once or more. For example, 'ZO "can match" ZO "and" ZOO ", but You cannot match "Z". Equivalent to {1,}. • Match the previous child expression zero or once. For example, "Do (es)" can match "do" in "do" or "does" .? Equivalent to {0,1}. {N} n is a non-negative integer. Match the N times. For example, 'o {2}' does not match 'O' in "Bob", but can match " Two o. {n,} n is a non-negative integer. At least n times. For example, 'o {2,}' does not match 'O' in "Bob", but can match "fooood" All O.'o {1,} 'is equivalent to' o '.' O {0,} 'is equivalent to' o * '. {N, m} M and N are non-negative integers, of which N <= m. minimum match N times and matched M times. Liu, "O {1, 3}" will match the top three O.'o {0, 1} 'in "foooood" is equivalent to' o ? '. Please note that there is no space between commas and two numbers. • When this character is tight in any other restriction (*, ,?, {N}, {n,}, {n, m} The match mode is not greedy. The non-greedy mode matches the search string as little as possible, and the default greed mode is as many as possible to match the search string. For example, for the string "OOOO", 'o ?' will match a single "O", and 'o ' will match all 'o'. Match any individual characters other than "/ n". To match any character, including '/ n', please Use the mode '[./n]' mode. (Pattern) matches Pattern and get this match. The acquired match can be obtained from the generated Matches collection, using the Submatches collection in VBScript, using {content} in JScript ... Property. To match the bracket character, please use '/ (' Or '/)'. (?: pattern) Match Pattern but does not acquire the matching result, that is, this is a non-acquired match, not to use it after storage.
This is useful to use the "or" character (|) to combine a pattern. For example, 'industr (?: Y | iES) is a smale of' Industry | Industries'. (? = pattern) Positive to check, match the lookup string at any string of Pattern. This is a non-acquisition match, that is, the match does not need to be used later. For example, 'Windows (? = 95 | 98 | NT | 2000)' Map "Windows" in Windows 2000, but does not match "Windows" in "Windows 3.1". It is not consumed by the character, that is, after a match occurs, start the next matching search immediately after the last match, not starting from the character containing the pre-check. (?! pattern) negotiation, match the lookup string at any string of any mismatch at any Point WHERE A STRING NOT MATCHING POINT WHERE A STRING NOT MATCHING PATTERN. This is a non-acquisition match, that is, the match does not need to be used later. For example, 'Windows (?! 95 | 98 | NT | 2000) "can match" Windows "in Windows 3.1, but cannot match" Windows "in" Windows 2000 ". It is not consumed by the character, that is, after a match occurs, start the next matching search immediately after the last match, not the X | Y, which matches X or Y after the character containing the queue. For example, 'Z | Food' can match "z" or "food". '(z | f) OOD' matches "Zood" or "Food". [XYZ] Character collection. Match any of the included characters. For example, '[abc]' can match 'a' in "Plain". [^ XYZ] Negative character set. Match any of the characters that are not included. For example, '[^ ABC]' can match 'P' in "Plain". [A-Z] character range. Match any of the characters within the specified range. For example, '[a-z]' can match any lowercase alphabetic characters in the 'A' to 'Z' range. [^ a-z] Negative character range. Match any of any characters that are not within the specified range. For example, '[^ a-z]' can match any of any characters that are not in the 'A' to 'Z'. / b Match a word boundary, that is, the location of the words and spaces. For example, 'er / b' can match 'ER' in "Never", but do not match 'Er' in "Verb". / B matches non-word boundary. 'ER / B' can match 'Er' in "Verb", but cannot match 'Er' in "Never". / CX matches the control character indicated by x. For example, / cm matches a Control-M or an Enterprise. The value of x must be one of A-Z or A-Z. Otherwise, the C is treated as a primary 'c' character. / d Match a numeric character.
Equivalent to [0-9]. / D Match a non-digital character. Equivalent to [^ 0-9]. / f Match a change page. Equivalent to / x0c and / cl. / n Match a newline. Equivalent to / x0a and / cj. / r Match a carriage return. Equivalent to / X0D and / cm. / s Match any blank character, including spaces, tabs, change page, and the like. Equivalent to [/ f / n / r / t / v]. / S Match any non-blank character. Equivalent to [^ / f / N / R / T / V]. / t matches a tab. Equivalent to / x09 and / ci. / v Match a vertical tab. Equivalent to / x0b and / ck. / w Match any word character that includes underscore. Equivalent to '[A-ZA-Z0-9_]'. / W Match any non-word characters. Equivalent to '[^ a-za-z0-9_]'. / XN matches n, where n is a hexadecimal escape value. The hexadecimal escape value must be a determined two numbers long. For example, '/ x41' matches "a". '/ x041' is equivalent to '/ x04' & "1". ASCII coding can be used in regular expressions. . / NUM matches NUM, where NUM is a positive integer. References to the acquired match. For example, '(.)' Matches two consecutive identical characters. / n identifies an octal escape value or a rearward reference. If the sub-expression of at least N before / N, n is a backward reference. Otherwise, if n is an octal number (0-7), then n is an eight-input escape value. / Nm identifies an octal escape value or a backward reference. If the / nm has at least IS Preceded by Least NM acquired a sub-expression, the nm is a backward reference. If there is at least n acquisitions before / nm, then n is a rear reference reference to the text M. If the previous conditions are not satisfied, if n and m are octal numbers (0-7), the / nm will match the eight-way escape value Nm. / Nml If n is an octal number (0-3), and M and L are eight-input numbers (0-7), match the eight-en-en-escaic value NML. / UN matches N, where N is a Unicode character represented by four hexadecimal numbers. For example, / u00A9 matches copyright symbol (?). Transfer from: http://www.phpe.net/articles/151.shtml