Post

Regex - Basics

Regex - Basics

1
2
3
4
5
^ start of a string
$ end of a string
. wildcard
| matches chars on either side (or)
\ escape

Special chars

1
2
3
4
5
6
7
8
9
10
11
\s whitespace
\S non-whitespace
\w word
\W non-word
\d one digit
\D one non-digit
\c control character
\n newline
\t tab
\r return
\0 null

Grouping

1
2
3
4
5
6
(xyz) group
(?:xyz) non group
[xyz] range
[^xyz] non range
[a-z] char in range
[0-9] digit in range

Websites to practice regex

  • https://regexlearn.com/
This post is licensed under CC BY 4.0 by the author.