Learn Java Programming - Regex Metacharacters Tutorial

Опубликовано: 03 Октябрь 2024
на канале: Daniel Ross
2,340
29

Metacharacters are ordinary characters that cause the compiled regex expression to be interpreted in a special way.
The following list of characters are all metacharacters with a brief description of what they commonly do :

. the period is a wildcard for any character (letter, number, symbol, etc.).
[] square brackets are used in character classes.
() parenthesis are used in capturing groups.
{} curly brackets are used in quantifiers.
\ the backslash is used to precede a metacharacter or a predefined character class. It is also used to indicate a Java escape sequence character.
^ the caret is used for negation or the beginning of a line.
- the dash is used for ranges.
& the ampersand is used for intersections.
= the equals is used for special construct lookahead.
$ the dollar sign is a boundary matcher for the end of a line.
! the exclamation mark is used for special construct lookbehind.
| the pipe is used for or expressions.
? the question mark is used in quantifiers and special constructs.
* the asterisk is used in quantifiers.
+ the plus is used in quantifiers.
, the comma is used in quantifiers.