Learn localStorage by Building a Todo App - Step 67

Tell us what’s happening:

I’m really struggling with my regex expression, from my understanding, everything inside the square brackets should be accepted, the “g” means it should check the whole string, and everything else should be removed.
Any pointers on where I’m going wrong?
Regex is really frying my brain!

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const removeSpecialChars = ((str) => {
 str = str.replace(/[A-Za-z0-9\ ]/g, "");
 return str;
});


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 67

you are removing alphanumeric characters with that regex, not keeping them. There is a way to negate a character class so to match everything but what’s inside it, maybe it’s what you want to use?

Thank you! I got there in the end, I was using the wrong thing for keeping the spaces in too.

1 Like