regex Flashcards
1
Q
.
A
anything, except line breaks
2
Q
\d
A
digit in 0123456789
3
Q
\D
A
non-digit
4
Q
\w
A
“word” (letters and digits and _)
5
Q
\W
A
non-word
6
Q
space
A
space
7
Q
\t
A
tab
8
Q
\r
A
return
9
Q
\n
A
new line
10
Q
\s
A
whitespace (any of tab, return, new line, space)
11
Q
\S
A
non-whitespace
12
Q
[…]; [aeiou]; [^aeiou]
A
character class; vowels; non-vowels (incl non-letters!)
13
Q
[a-e] [x-y] [0-9]; [a-e0-9]
A
range of letters / numbers; abcde0123456789
14
Q
\b
A
word boundary
15
Q
\B
A
non-word boundary
16
Q
A
beginning of line
17
Q
$
A
end of line
18
Q
(X|Y)
A
X or Y
19
Q
X*
A
0 or more repetitions of X (wut? 0?)
20
Q
X+
A
1 or more repetitions of X
21
Q
X?
A
0 or 1 instances of X
22
Q
X{m}
A
exactly m instances of X
23
Q
X{m,}
A
at least m instances of X
24
Q
X{m,n}
A
between m and n (inclusive) instances of X
25
ab+ / (ab)+ -- what's the difference?
ab+ matches ab, abb, abbb, etc. (ab)+ matches ab, abab, ababab...
26
Characters that should be escaped (\) to match:
{} [] () ^$ . | * + ? \ (and - inside [ ]). \. matches the period, \\ matches the backslash