Any letter in a regex expression that is followed by a *
does not have to occur in the string tested whereas any letter in a regex expression followed by a +
must occur in a string at least once, as shown below,
let phrase = "ba humbug";
let regexPlus = /bah+/;
let regexStar = /bah*/;
regexPlus.test(phrase); // returns false
regexStar.test(phrase); // returns true
Both allow for any number of occurrences of the same letter in a row, for example,
let phrase = "wooooow look at that!";
let regexPlus = /wo+w/;
let regexStar = /wo*w/;
regexPlus.test(phrase); // returns true
regexStar.test(phrase); // returns true
example:
Create a regex chewieRegex
that uses the *
character to match all the upper and lower"a"
characters in chewieQuote
. Your regex does not need flags, and it should not match any of the other quotes.
let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /change/; // Change this line
let result = chewieQuote.match(chewieRegex);
let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /Aa*/;
let result = chewieQuote.match(chewieRegex);