regex Flashcards
.
anything, except line breaks
\d
digit in 0123456789
\D
non-digit
\w
“word” (letters and digits and _)
\W
non-word
space
space
\t
tab
\r
return
\n
new line
\s
whitespace (any of tab, return, new line, space)
\S
non-whitespace
[…]; [aeiou]; [^aeiou]
character class; vowels; non-vowels (incl non-letters!)
[a-e] [x-y] [0-9]; [a-e0-9]
range of letters / numbers; abcde0123456789
\b
word boundary
\B
non-word boundary
beginning of line
$
end of line
(X|Y)
X or Y
X*
0 or more repetitions of X (wut? 0?)
X+
1 or more repetitions of X
X?
0 or 1 instances of X
X{m}
exactly m instances of X
X{m,}
at least m instances of X
X{m,n}
between m and n (inclusive) instances of X
ab+ / (ab)+ – what’s the difference?
ab+ matches ab, abb, abbb, etc. (ab)+ matches ab, abab, ababab…
Characters that should be escaped () to match:
{} [] () ^$ . | * + ? \ (and - inside [ ]). . matches the period, \ matches the backslash