Regular Expressions Flashcards

1
Q

Regular expressions are used in programming languages to …

A

match parts of strings. You create patterns to help you do that matching.

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

The _____ method takes the regex, applies it to a string (which is placed inside the parentheses), and returns true or false if your pattern finds something or not.

A

.test()

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

The wildcard character . will match any one character. The wildcard is also called dot and period. You can use the wildcard character just like any other character in the regex. For example, if you wanted to match “hug”, “huh”, “hut”, and “hum”, you can use the regex /hu./ to match all four words.

A

s

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

You can search for a literal pattern with some flexibility with character classes. Character classes allow you to define a group of characters you wish to match by placing them inside square ([ and ]) brackets.

A

s

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

So far, you have created a set of characters that you want to match, but you could also create a set of characters that you do not want to match. These types of character sets are called negated character sets.

A

s

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

The last challenge used the plus + sign to look for characters that occur one or more times. There’s also an option that matches characters that occur zero or more times.

The character to do this is the asterisk or star: *.

A

s

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