^
and $
- “tie” the matches of the rest of the regular expression to the beginning and end of the string, respectively. For example, ^cat
matches the strings "cat" and "caterpillar", and dog$
with the strings "bulldog" and "hotdog".[…]
- character classes allow you to list characters that can be in a given position of the text. For example, gr[ea]y
will match the strings “gray” and “gray”.[^…]
- excluding character classes allow you to list characters that can not be in a given position of the text. For example, g[^ae]rdy
does not match the strings "gardy" and "gerdy", but will coincide with the strings "gurdy", "g3rdy" and "girdy".(…|…)
- design choice , the choice of several options. It should be noted that each part of the construction of choice is a full-fledged regular expression . For example, Jeff(re|er)y
matches the strings “Jeffrey” and “Jeffery”.\<
and \>
- metasequences are an analogue of ^ and $ but at the level of words. For example, \<cat\>
matches the single word cat.Regex metacharacters | ||
---|---|---|
Symbol | Title | Interpretation |
Elements denoting a single character | ||
. | point | one any character |
[…] | character class | any of the listed characters |
[^…] | inverted character class | any character not listed in class |
\ | screening | if the character is preceded by the escape prefix "\", then the character is interpreted as the corresponding literal |
Quantifiers | ||
? | question mark | one copy is allowed (none required) |
* | star | any number of copies allowed (none required) |
+ | a plus | one copy is required, any number of copies allowed |
{min, max} | interval quantifier * | “min” instances required, “max” results allowed |
Positional metacharacters | ||
^ | cover, circumflex | position at the beginning of the line |
$ | dollar | position at the end of the line |
\< | word boundary * | position at the beginning of the word |
\> | word boundary * | position at the end of a word |
Other metacharacters | ||
| | selection design | any of the listed expressions |
(…) | round brackets | constraint for choice construction, grouping for applying quantifiers, and saving text for backlinks |
\1, \2, … | back link | text that previously matched the first, second, etc. pairs of parentheses |
Source: https://habr.com/ru/post/55843/
All Articles