Regular Expressions - Check For Mixed Grouping of Characters

Tell us what’s happening:
I dont know how to make an optional middle name

Your code so far

let myString = "Eleanor Roosevelt";
let myRegex = /(Eleanor|Franklink)\sRoosevelt/; // Change this line
let result = myRegex.test(myString); // Change this line
// After passing the challenge experiment with myString and see how the grouping works

Your browser information:

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

Challenge: Regular Expressions - Check For Mixed Grouping of Characters

Link to the challenge:

What does the middle name that is tested look like? How could you describe that middle name using regex?

it is D. but I dont know how to make an optional one

You probably don’t only want to match “D.”, but how would you describe a middle initial like that using regex?

How did you check for an optional https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/check-for-all-or-none

should I put “D.” in a bracket or in a parenthesis

You should not create code that only passes the tests but would fail for every single other middle initial.

/(Eleanor|Franklink)(\s..)?\sRoosevelt/

how is this one because i am confuse how I can use period as a character other than its other use which is to match any other character

I don’t know which Challenge it is, but you need to ‘escape’ special characters with a \

i have created a new post can you help me on that one

Mod Edit :SOLUTION REMOVED

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

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