Regex Flashcards
Source: https://cheatography.com/davechild/cheat-sheets/regular-expressions/pdf/
Anchors — what do they do?
Anchors do not match any character at all. Instead, they match a position before, after, or between characters.
source: https://www.regular-expressions.info/anchors.html
*
Quantifier: 0 or more
+
Quantifier: 1 or more
?
Quantifier: 0 or 1
Can also be added to another quantifier to make it ungreedy
{3}
Quantifier: Exactly 3
{3,}
Quantifier: 3 or more
{3,5}
Quantifier: 3, 4, or 5
Anchor: Start of string, or start of line in a multi-line pattern
\A
Anchor: Start of string
$
Anchor: End of string, or end of line in multi-line pattern
\Z
Anchor: End of string
\b
Anchor: Word boundary
\B
Anchor: Not word boundary
\⋜
Anchor: Start of word
>
Anchor: End of word
Three positions that count as word boundaries
- Before the first character in the string, if the first character is a word character.
- After the last character in the string, if the last character is a word character.
- Between two characters in the string, where one is a word character and the other is not a word character.
Source: https://www.regular-expressions.info/wordboundaries.html
\c
Character Class: Control character
\s
Character class: white space
\S
Character class: Not white space
\d
Character class: digit
\D
character class: Not digit
\w
Character class: word
\w
Character class: \w
\W
Character class: Not word
\x
Character class: Hexadecimal digit
\O
Character class: octal digit