Tell us what’s happening:
Describe your issue in detail here.
Your code so far
// Only change code below this line
let chewieRegex = /aa*a/ig; // Change this line
// Only change code above this line
let result = chewieQuote.match(chewieRegex);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Challenge: Regular Expressions - Match Characters that Occur Zero or More Times
The regex /aa*a/ig is a pattern that can be used to match a string that contains one or more ‘a’ characters, followed by zero or more ‘a’ characters, and then followed by a single ‘a’ character. Here is a breakdown of the components of the regex:
/ and /ig: These are delimiters that mark the beginning and end of the regex pattern. The ‘i’ and ‘g’ flags at the end of the regex enable case-insensitive and global matching, respectively.
a: This is a literal ‘a’ character.
a*: This matches zero or more occurrences of ‘a’.
a: This is a literal ‘a’ character.
Based on this, the regex will match any of the following patterns in a string:
‘a’
‘aa’
‘aaa’
‘aaaa’
‘aaa…a’ (where there are any number of ‘a’ characters)
It will not match any strings that do not contain at least one ‘a’ followed by another ‘a’ character.
@nhcarrigan, Thank you for your feedback and for letting me know that the regex passes on your end. It’s possible that there are some differences in the way our environments handle the regex.
I apologize for any confusion caused by the discrepancy between the regex and the challenge description. I will review the challenge and the regex to ensure that they are consistent and accurate.
In the meantime, adding additional tests is a great suggestion to ensure that the regex is working correctly across different environments. I will work on incorporating more tests to make sure that the regex is functioning as intended.