Regex Expressions

Standard

Meta-characters

Anchors –
^ – beginning of the line
$ – end of the line

Quantifier –
{n} – appear n times (applies to a part of the pattern called an atom
? – 0 or 1 time
* – any number of times [ can be none at all]
+ – 1 or more number of time

Altercation –
The | meta-character is like the conjunction “or”; it means either the previous atom or the next atom.

Useful link for learning more on Regular Expression and the language in which they’re most at home i.e. perl

List of Meta-characters

\w – matches a alphanumeric character
\d – matches a number
\s – matches a space
\W, \D, \S – opposite of \w, \d, \s
^ – beginning of line
$ – end of line character
. – match any character except for newline
* – 0 or more occurrence
+ – 1 or more occurrence
? – 0 or 1 occurrence
| – alternative match
(regex) – grouping/store match
[ ] – character set/class
{ x,y } – number of occurrence between x and y
{ x } – x occurrence
{ x, } – at least x occurrence
[^ ] – opposite of [ ]
*? – non greedy matching

Leave a comment