JavaScript RegExps Flashcards

0
Q

$

A

Matches end of input

/end$/ matches “This is the end”

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

Matches beginning of input

/^This/ matches “This is…”

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

*

A

Matches zero or more times

/se*/ matches “seeee” as well as “se”

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

?

A

Matches zero or one time

/ap?/ matches “apple” and “and”

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

+

A

Matches one or more times

/ap+/ matches “apple” but not “and”

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

{n}

A

Matches exactly n times

/ap{2}/ matches “apple” but not “apie”

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

{n,}

A

Matches n or more times

/ap{2,}/ matches all p’s in “apple” and “apppple” but not “apie”

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

{n,m}

A

Matches at least n times, at most m times.
/ap{2,4}/ matches four p’s in
“apppppple”

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

.

A

Any character except newline

/a.e/ matches “ape” and “axe”

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

[…]

A

Any character within brackets

/a[px]e/ matches “ape” and “axe” but not “ale”

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

[^…]

A

Any character but those within brackets

/a[^px]/ matches “ale” but not “ape” or “axe”

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

\b

A

Matches on word boundary

/\bno/ matches the first “no” in “nono”

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

\B

A

Matches on non word boundary

/\Bno/ matches the second “no” in “nono”

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

\d

A

Digits from 0 to 9

/\d{3}/ matches 123 in “Now in 123”

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

\D

A

Any non digit character

/\D{2,4}/ matches “Now” in “Now in 123”

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

\w

A

Matches word character (letters, digits, underscores)

/\w/ matches “j” in javascript

16
Q

\W

A

Matches any nonword character (not letters, digits, or underscores)
/\W/ matches “%” in “100%”

17
Q

\n

A

Matches a line feed

18
Q

\s

A

A single whitespace character

19
Q

\S

A

A single character that is not whitespace

20
Q

\t

A

A tab

21
Q

(x)

A

Capturing parentheses

Remembers the matches characters