Regex Flashcards

1
Q

Simple Class:

A

[abc]

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

[abc]

Matches on

A

a, b, or, c

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

Negation of class

A

[^abc]

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

[^abc]

Matches on

A

Any character except for a, b, or, c

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

Range class:

A

[a-zA-Z]

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

[a-zA-Z]

Matches on

A

a through z or A through Z inclusive

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

Union of ranges

A

[a-d[m-p]]

A single class that combines two seperate ranges

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

[a-d[m-p]]

Matches

A

Characters a through d or characters m through p inclusive

This is a union of ranges

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

Intsersection of classes:

A

[a-z&&[def]]

Creates a single class that will only match on characters that are in each sub class

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

[a-z&&[def]]

Matches on

A

Characters d, e, and f

This is an intersection and only matches on characters in both [a-z] and [def]

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

Subtraction:

A

[a-z&&[^m-p]

Creates a single class that will only match on characters that are in one class but not the other i.e. anything between a-z as long as it’s not between m-p inclusive

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

[a-z&&[^m-p]]

Matches on

A

Anything between a-z that is not between m-p

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

Predefined Class

Match any character

A

.

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

Predefined class

.

Matches

A

Any character

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

Predefined Class

Match any digit

A

\d

Equal to the class [0-9]

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

Predefined Class

\d

Matches

A

Any digit

[0-9]

17
Q

Predefined Class

Match any non-digit character

A

\D

Equal to: [^0-9]

18
Q

Predefined Class

\D

Matches

A

Any non-digit

[^0-9]

19
Q

Predefined Class

Match a whitespace

A

\s

Equal to: [\t\n\x0B\f\r]

20
Q

Predefined Class

/s

Matches

A

Any whitespace character

[\t\n\x0B\f\r]

21
Q

Predefined Class

Match any non whitespace character

A

\S

Equal to: [^\s]

22
Q

Predefined Class

/S

Matches

A

Any non-whitespace character

[^\s]

23
Q

Predefined Class

Match any word character

A

\w

Equal to: [a-zA-Z_0-9]

24
Q

Predefined Class

\w

Matches on

A

Any word character

[a-zA-Z_0-9]

25
Q

Predefined Class

Match any non-word character

A

\W

Equal to: [^\w]

26
Q

Predefined Class

\W

Matches on

A

Any non-word character

[^\w]