RegEx Quantifiers Flashcards

1
Q

Matches any string that contains at least one n

A

n+

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

Matches any string that contains zero or more occurrences of n

A

n*

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

Matches any string that contains zero or one occurrences of n

A

n?

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

Matches any string that contains a sequence of X n’s

A

n{X}

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

Matches any string that contains a sequence of X to Y n’s

A

n{X,Y}

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

Matches any string that contains a sequence of at least X n’s

A

n{X,}

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

Matches any string with n at the end of it

A

n$

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

Matches any string with n at the beginning of it

A

^n

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

Matches any string that is followed by a specific string n

A

?=n

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

Matches any string that is not followed by a specific string n

A

?!n

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

RegExp.$1-$9

A

Description
The $1, …, $9 properties are static, they are not a property of an individual regular expression object. Instead, you always use them as RegExp.$1, …, RegExp.$9.

The values of these properties are read-only and modified whenever successful matches are made.

The number of possible parenthesized substrings is unlimited, but the RegExp object can only hold the first nine. You can access all parenthesized substrings through the returned array’s indexes.

These properties can be used in the replacement text for the String.replace method. When used this way, do not prepend them with RegExp. The example below illustrates this. When parentheses are not included in the regular expression, the script interprets $n’s literally (where n is a positive integer).

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