Regular expression symbols and special characters

xiaoxiao2021-03-05  22

Regular expression symbol character Description / Mark Next character is a special character or text. For example, "n" and character "n" match. "/ n" is matched with the wrap character. Sequence "//" and "/" match, and "/ (", and "match. ^ Match the beginning of the input. $ Match the end of the input. * Match the previous character zero or multiple. For example," ZO * "Z" or "zoo" matches. Match the previous character once or multiple times. For example, "ZO " matches "ZOO", but and "z" does not match.? Match the previous character zero or once. For example, "VE" match in "a? Ve?" And "Never" match. Match any single character outside of the wrap character. (Pattern) matches Pattern and remembers the match. Match the sub-string, you can use Item [0] [N] to retrieve from the generated Matches collection. To match the bracket character (), you need to use "/ (" or "/)".x|y match x or y {n } n is a non-negative integer. Match N times {n,} n is a non-negative integer. At least n times. For example, "o" in "o" in "O" in "bob" does not match, but " All O matches in fooood. "o {1,}" is equivalent to "O " equivalent. "o {0,}" and "o *" equivalent. {n, m} m and n are non-negative integers. At least Match N times and match M times. For example, the first three O match in "o {1, 3}" and "foooood". "O {0, 1}" and "o?" Are equivalent. [Character collection Match any of the characters in brackets. For example, "A" match in "[ABC]" and "Plain". [^ XYZ negative character set. Match any character in harness. For example, "[^ ABC]" And "P" in "PLAIN" match. [AZ] character range. Match any of the specified ranges. For example, "[AZ]" matches "A" to "A" to "Z" range any lower-write letter Table characters. [^ Mz] negative character range. Matching any characters not within the specified range. For example, "[MZ]" matches any character in "M" to "z" range. / B match the boundary, also That is, in the position between words and spaces. For example, "ER" in "er / b" and "Never" match, but "er" in "verb" does not match. / B Match the non-word boundary. "EA * R / B" and "NEVER EARLY" match. / D match numeric characters. Equivalent to [0-9]. / D matches non-numeric characters. Equivalent to [^ 0-9] . / F Match the page character. / N Match the charter character. / R Match Enter Character. / S Match any blank, including spaces, Table, change the page, etc. Equivalent to "[/ F / N / R / T / V]". / S Match any non-blank character. Equivalent to "[^ / f / N / R / T / V]". / t matches the table character. / v Match the vertical tab. / W Match any word including underline.

Equivalent to "[A-ZA-Z0-9_]. / W Match any non-character. Equivalent to "[^ a-za-z0-9_]. / NUM matches NUM, where NUM is a positive integer. Returns a reference to the match. For example, "(.) / 1" matches two consecutive identical characters. / n Match N, where N is an octal exchange value. The eight-in-circuit modified value must be 1, 2, or 3 long. For example, "/ 11" and "/ 011" match the table character. "/ 0011" and "/ 001" & "1" are equivalent. The octal demobilization value must not exceed 256. If it exceeds, only the first two constitutive expressions. Allows the use of the ASCII code in the regular expression. / XN matches N, where N is a hexadecimal exchange value. The hexadecimal modified value must be just two long. For example, "/ x41" matches "A". "/ x041" and "/ x04" & "1" are equivalent. Allows the use of the ASCII code in the regular expression.

Special characters in the regular expression 〓 Introduction 〓 Character Significance: For characters, it is usually represented by literal meaning, indicating that the characters are special characters, not explained. 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 *'. 〓 Text 〓 Character Significance: For characters, it is usually represented by literal meaning, indicating that the characters are special characters, not explained. 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 booooed", but does not match any of the "a Goat 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' in" CaaaaAAAandy. ". 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 by the group in the result array [1], ..., [n], or returned by the property of the regexp object, ..., $ 9.

Character X | Y Sign: Match 'x' or 'Y'. For example: / Green | RED / Match 'Red' in 'Green' in "Green Apple". 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 [B] Significance: Match a space (do not confuse with B) Character B Significance: Match a word line, such as a space (do not confuse with [b]), for example: / bnw / match "noonday" in 'NO ', / Wyb / match "Possibly YesterDay."' 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].

转载请注明原文地址:https://www.9cbs.com/read-38845.html

New Post(0)