Regular Expressions Flashcards
Regular expressions are used in programming languages to …
match parts of strings. You create patterns to help you do that matching.
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.
.test()
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.
s
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.
s
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.
s
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: *.
s