Section 1

Preview this deck

What does the backslash represent in a regular expression?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (21)

Section 1

(21 cards)

What does the backslash represent in a regular expression?

Front

Matches according to the following rules: A backslash that precedes a non-special character indicates that the next character is special and is not to be interpreted literally. A backslash that precedes a special character indicates that the next character is not special and should be interpreted literally. Do not forget to escape \ itself while using the RegExp("pattern") notation because \ is also an escape character in strings.

Back

What does String.prototype.split do?

Front

Back

Describe the four types of parentheses

Front

Capturing Parentheses: (x) groups x and "remembers" what it matched Non-Capturing Parentheses: (?:x) groups x but does not "remember" what it matched Lookahead: x(?=y) Matches 'x' only if 'x' is followed by 'y'. y is not part of the match results. Negated lookahead: x(!=y) Matches 'x' only if 'x' is NOT followed by 'y'. y is not part of the match results.

Back

What does '\b' match?

Front

A word boundary. A word boundary matches the position between a word character followed by a non-word character, or between a non-word character followed by a word character, or the beginning of the string, or the end of the string. A word boundary is not a "character" to be matched; like an anchor, a word boundary is not included in the match.

Back

What does '\w' match?

Front

A word character: any alphanumeric character including the underscore. Equivalent to [A-Za-z0-9_].

Back

How do you match the beginning of the input?

Front

^

Back

How do you create a regular expression dynamically?

Front

Use the RegEx constructor

Back

What does the String.prototype.match function do?

Front

If the global flag is set, no capturing groups will be stored in the array (only matches)

Back

How do you match the backspace?

Front

[\b]

Back

How do you create a RegEx literal?

Front

put the regular expression between two forward slashes

Back

How do you match the end of the input?

Front

$

Back

What does the String.prototype.replace function do?

Front

remember that to replace all matches the 'g' flag is needed (if a string is given instead of a RegExp, only the first match can be replaced) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

Back

What does '\d' match?

Front

A digit

Back

What are the regular expression flags?

Front

Back

What does the '.' character match?

Front

Any single character expect the newline character.

Back

Describe the three uses of curly braces

Front

{n} means match the previous character/group exactly n times {n,} means match the previous character/group at least n times {n, m} means match the previous character/group between n and m times (n must be < m)

Back

What does the '?' character match?

Front

The preceding character 0 or 1 times

Back

What does the String.prototype.search function do?

Front

A String method that tests for a match in a string. It returns the index of the match, or -1 if the search fails.

Back

What does the RegExp.prototype.exec function do?

Front

With a global search repeated calls to exec return the next match in the string (the array will still have the capturing groups). The result also has a input property with the original string.

Back

What does the RegExp.prototype.test do?

Front

A RegExp method that tests for a match in a string. It returns true or false.

Back

What are character sets/negated character sets?

Front

Character Set: [xyz] matches a single character which is one of x, y, z (special characters in the set are treated literally) Negated Character Set: [^xyz] matches a single character which not one of x, y, or z (special characters in the set are treated literally)

Back