What are the operators in regular expressions
This article will explain in detail what operators there are in regular expressions. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
I. ordinary characters
Includes all printed and non-printed characters that are not explicitly specified as metacharacters, such as uppercase and lowercase letters, numbers, punctuation, and so on.
Second, metacharacter
Metacharacters are characters that have a special meaning in regular expressions. Because metacharacters have a special meaning in regular expressions, these characters cannot be used to represent themselves and must be escaped by prefixing it with a backslash. The resulting escape sequence will match the character itself rather than its special metacharacter meaning. If [represents the beginning of a character set, if you want to match [in a regular expression, you need to refer to:\ [to represent [itself.
^ matches the start position of the input string unless used in a square bracket expression, where it indicates that the character collection is not accepted. To match the ^ character itself, use\ ^. $matches the end of the input string. If multiline matching is set, $also matches'\ n' or'\ r'. To match the $character itself, use\ $. () marks the start and end positions of a subexpression. Subexpressions can be obtained for later use. To match these characters, use [Math Processing Error]. ? Matches the previous subexpression zero or once, or indicates a non-greedy qualifier. To play Standard PvP match? Characters, please use\? * matches the previous subexpression zero or more times. To match the * character, use\ *. + matches the previous subexpression one or more times. To match the + character, use\ +. . Matches any single character except the newline character\ n. To match., use\. [] marks the beginning and end of a character collection. To match [or], use [Math Processing Error]. \ Mark the next character as a special character, or literal character, or backward reference, or octal escape character. For example,'n' matches the character'n'. \ n' matches the newline character. The sequence'\ 'matches "\", while'\ ('matches "(". | indicates a choice between the two items. To match |, use\ |. {} marks the beginning and end of the qualifier expression. To match {or}, use\ or\}.
III. Non-print characters
\ cx matches the control characters indicated by x. For example,\ cM matches a Control-M or carriage return. The value of x must be one of Amurz or aMuz. Otherwise, c is treated as a literal'c 'character. \ f matches a feed character. Equivalent to\ x0c and\ cL. \ nmatches a newline character. Equivalent to\ x0a and\ cJ. \ r matches a carriage return. Equivalent to\ x0d and\ cM. \ t matches a tab. Equivalent to\ x09 and\ cI. \ v matches a vertical tab. Equivalent to\ x0b and\ cK.
IV. Predefined characters
. Any character (which may or may not match the Terminator)\ d number is equivalent to [0-9]\ D non-numeric, equivalent to [^ 0-9]\ s white space character, equivalent to [\ t\ n\ x0B\ f\ r]\ S non-white space character, equivalent to [^\ s]\ w word character, equivalent to [a-zA-Z_0-9]\ W non-word character Equivalent to the front or back boundary of [^\ w]\ b words\ B represents a non-word boundary
5. POSIX characters
[: alnum:] any letter or number is equivalent to [a-zA-Z0-9] [: alpha:] any letter, equivalent to [a-zA-Z] [: blank:] space or tab, equivalent to [\ t] [: cntrl:] ASCII control character (ASCII 0 to 31, plus ASCII127) [: digit:] any number is equivalent to [0-9] [: graph:] any printable character But excluding spaces [: lower:] any lowercase letter is equivalent to [an alnum] [: print:] any printable character [: space:] that neither belongs to [: alnum:] or [: cntrl:] any white space character, including spaces, is equivalent to [^\ f\ n\ r\ t\ v] [: upper:] any uppercase letter. Equivalent to [Amurz] [: xdigit:] any hexadecimal number, equivalent to [a-fA-F0-9]
VI. Qualifier
* matches the previous subexpression zero or more times. For example, zo* can match "z" and "zoo". * is equivalent to {0,}. + matches the previous subexpression one or more times. For example, 'zo+' can match "zo" and "zoo", but not "z". + is equivalent to {1,}. ? Matches the previous subexpression zero or once. For example, "do (es)?" Can match "do" in "do" or "does". ? It is equivalent to {0jue 1}. {n} n is a non-negative integer. Match the determined n times. For example,'o {2} 'does not match the' o'in 'Bob', but does match the two o in 'food'. {n,} n is a non-negative integer. Match at least n times. For example,'o {2,} 'does not match' o'in 'Bob', but does match all o in 'foooood'. O {1,}'is equivalent to 'oasis'. O {0,}'is equivalent to 'oval'. {n ·m} m} m and n are non-negative integers, where n