regex Flashcards

1
Q

.

A

anything, except line breaks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

\d

A

digit in 0123456789

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

\D

A

non-digit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

\w

A

“word” (letters and digits and _)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

\W

A

non-word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

space

A

space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

\t

A

tab

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

\r

A

return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

\n

A

new line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

\s

A

whitespace (any of tab, return, new line, space)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

\S

A

non-whitespace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

[…]; [aeiou]; [^aeiou]

A

character class; vowels; non-vowels (incl non-letters!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

[a-e] [x-y] [0-9]; [a-e0-9]

A

range of letters / numbers; abcde0123456789

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

\b

A

word boundary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

\B

A

non-word boundary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
Q

ab+ / (ab)+ – what’s the difference?

A

ab+ matches ab, abb, abbb, etc. (ab)+ matches ab, abab, ababab…

26
Q

Characters that should be escaped () to match:

A

{} [] () ^$ . | * + ? \ (and - inside [ ]). . matches the period, \ matches the backslash