Regular Expression - Meta-(symbols|characters) - Operator

Regexp

About

There are two different sets of meta-characters:

  • those that are recognized anywhere in the pattern except within square brackets,
  • and those that are recognized in square brackets.

Square brackets

Outside

Operator Description Example
Escape
\ general escape character with several uses. It can:
* Stand for itself,
* Quote the next character,
* Introduce an operator,
* Do nothing
Quantifier
* Matches 0 or more occurrences
of the preceding element
ab*c matches “ac”, “abc”, “abbc”, “abbbc”, and so on
+ Matches 1 or more occurrences
of the preceding element
ab+c matches “abc”, “abbc”, “abbbc”, and so on, but not “ac”
? Matches 0 or 1 occurrence
of the preceding element
colou?r matches both “color” and “colour”
{ start min/max quantifier
} end min/max quantifier
{m} Matches exactly m times
{m,} Matches at least m times
{m,n} Matches at least m times but no more than n times
Boundary
^ Matches the beginning of a string by default.
(or line, in multiline mode)
$ Matches the end of a string by default.
(or line, in multiline mode)
[hc]at$ matches “hat” and “cat”, but only at the end of the string or line.
Logical Matcher
| Boolean “or” - start of alternative branch to specify alternative matches gray|grey can match “gray” or “grey”
Character
. dot Matches any character in the supported character set except NULL .at matches any three-character string ending with “at”, including “hat”, “cat”, and “bat”. Dot may not match newlines, option is required
Character Class
[ start character class definition
] end character class definition
Grouping
( start subpattern See grouping expression
) end subpattern See grouping expression
( ) Grouping expression, treated as a single subpattern gray|grey and gr(a|e)y are equivalent patterns which both describe the set of “gray” and “grey”
Greedy Lazy matching
? Regular Expression - (Lazy|Reluctant) Quantifier

Inside

See Meta in class





Discover More
Regexp
Multilingual Regular Expression Syntax (Pattern)

Regular expression are Expression that defines a pattern in text. This is therefore a language that permits to define structure of a text. They are a mathematically-defined concept, invented by Stephen...
Regexp
Regexp - Backslash

Backslash is the general escape meta-character with several uses. It can: Stand for itself, Quote the next character, Introduce an operator, Do nothing see The third use of backslash...
Regexp
Regexp - Character Class (Character Set)

A character class defines a domain of permitted characters. character set ASCII characters with square brackets where: [ is the start character class definition ] is the end character class...
Regexp
Regexp - Escape Character

The escape character in a regular expression is the backslash. It's needed when the regular expression want to design a meta characters in a regular expression. It takes away any special meaning that...
Regexp
Regular Expression - Boundary Matcher

The boundary matcher meta Symbol Description ^ The beginning of a line $ The end of a line \b A word boundary \B A non-word boundary \A The beginning of the input \G The end of the previous...



Share this page:
Follow us:
Task Runner