Regular Expressions - Check For Mixed Grouping of Characters

Tell us what’s happening:
I had the exact same code as the solution and it has said that my code is wrong… can someone please help?

Your code so far

let myString = "Eleanor Roosevelt";
let myRegex = /(Franklin|Eleanor) (([A-Z]\.?|[A-Z][a-z]+))? Roosevelt/; // Change this line
let result = myRegex.test(myString); // Change this line


// After passing the challenge experiment with myString and see how the grouping works.

/*let myString = "Eleanor Roosevelt";
let myRegex = /(Franklin|Eleanor) (([A-Z]\.?|[A-Z][a-z]+) )?Roosevelt/;
let result = myRegex.test(myString);*/

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Regular Expressions - Check For Mixed Grouping of Characters

Link to the challenge:

You are very very close. Let me ask you this. How many spaces is your regex requiring between the first name and last name? How many spaces are in the string “Eleanor Roosevelt”?

Franklin D. Roosevelt

Problem is the spacing not matched. You have succesfully capture D. , why not treat the ‘white space’ in same capture groupipng ?

Franklin (D. )Roosevelt

I always make use of to graphically see how it matches.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.