In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian would like to share with you an example analysis of operator priority in regular expressions. I hope you will learn something after reading this article. Let's discuss it together.
Regular expressions are evaluated from left to right and follow the order of priority, which is very similar to arithmetic expressions.
The operation with the same priority is performed from left to right, and the operation with different priority is high and then low. The following table illustrates the precedence order of the various regular expression operators from highest to lowest:
Operator description\ escape character (), (?:), (? =), [] parentheses and square brackets *, +,?, {n}, {n,}, {n ~ () m} qualifier ^, $,\ any metacharacter, any character anchor and sequence (that is, position and order) | replace, OR operation
Characters take precedence over the replacement operator so that "m | food" matches "m" or "food". To match "mood" or "food", use parentheses to create a subexpression that produces "(m | f) ood".
Today's table is a classified summary of metacharacters in the overall regular expression syntax. Help memorize metacharacters. As above, the document is reproduced to MSDN.
Operator
The following table illustrates the precedence order of the various regular expression operators from highest to lowest:
Operator
Description
\
Escape character
(), (?), []
Parentheses and square brackets
*, +,?, {n}, {n,}, {nrecom}
Qualifier
^, $,\ any metacharacter, any character
Anchor point and sequence
| |
Replace
Characters take precedence over the replacement operator so that "m | food" matches "m" or "food". To match "mood" or "food", use parentheses to create a subexpression that produces "(m | f) ood".
Special character table
Special character
Annotation
$
Matches the position at the end of the input string. If the Multiline property of the RegExp object is set, $also matches the previous position\ n or\ r. To match the $character itself, use\ $.
(.)
Marks the beginning and end of the subexpression. You can capture subexpressions for later use. To match these two characters, use\ (and\).
*
Matches the previous character or subexpression zero or more times. To match the * character, use\ *.
+
Matches the previous character or 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 of the parenthesized expression. To match these characters, use\ [and\].
?
Matches the previous character or subexpression zero or once, or indicates a "non-greedy" qualifier. If you want to match? Characters, please use\?
\
Marks the next character as a special character, text, backreference, or octal escape character. For example, the character n matches the character n. \ nmatches the newline character. Sequence\\ match\, sequence\ (match (.
/
Represents the beginning or end of a text regular expression. To match / characters, use\ /.
^
Matches the position at the beginning of the input string, except when used in square bracket expressions, in which case it inverts the character set. To match the ^ character itself, use\ ^.
{}
Marks the beginning of the qualifier expression. To match these characters, use\ {and\}.
| |
Indicates that a choice is made between two items. To match |, use\ |.
Qualifier meaning
Character
Description
*
Matches the previous character or subexpression zero or more times. For example, zo* matches z and zoo. * equivalent to {0,}.
+
Matches the previous character or subexpression one or more times. For example, zo+ matches zo and zoo, but not z. + is equivalent to {1,}.
?
Matches the previous character or subexpression zero or once. For example, do (es)? Matches the do in do or does. ? It is equivalent to {0jue 1}.
{n}
N is a non-negative integer. It happens to match n times. For example, o {2} does not match o in Bob, but matches 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 matches all o in foooood. O {1,} is equivalent to o +. O {0,} is equivalent to o *.
{n,m}
M and n are non-negative integers, where n
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un