Regular Expressions - Check For Mixed Grouping of Characters

I’m trying to understand the solution given.

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

There is a space here ) )?
When I check without it, it doesn’t pass. What is that space doing? Is it checking for white space?

Challenge: Regular Expressions - Check For Mixed Grouping of Characters

Link to the challenge:

I think the following screenshot gives the answer to your question:

Try to browse the Web a little to get a better explanation.

The example from the challenge:

1 Like

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