Just a bit confused why one is working and the other is return an error because this REGEX is killing me.
Getting X
for :
Your regex `myRegex` should return `true` for the string `Franklin D. Roosevelt
Working:
let myRegex = /^(Franklin|Eleanor)(\s | [A-Z]\.)?\sRoosevelt/g; // Change this line
Failing to Match:
let myRegex = /^(Franklin|Eleanor)(\s|[A-Z]\.)?\sRoosevelt/g; // Change this line
The “Working” passes the lesson.
Just that there does not appear to be consistancy with the REGEX as perfect example: the ^(Franklin|Eleanor)
does not have a space but it is working fine.
Any help / clarification would be greatly appreciated.
Thank you in advance!!
Your code so far
let myString = "Franklin D. Roosevelt";
let myRegex = /^(Franklin|Eleanor)(\s | [A-Z]\.)?\sRoosevelt/g; // Change this line
let result = myRegex.test(myString); // Change this line
let print = myString.match(myRegex);
// After passing the challenge experiment with myString and see how the grouping works
console.log(result);
console.log(print);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36
Challenge: Check For Mixed Grouping of Characters
Link to the challenge: