RegExp is a powerful and succinct tool! For those participants who are looking for a course I recommend that you watch Mastering Regular Expressions in JavaScript by Steven Hancock. Believe me or not but the syntax seems to be complex or wierd. Once you pass the course - an expression like this one would be a piece of cake.
Comments
Lenry Kabua year ago
Removes all non alphabet chars
Anurag Arwalkara year ago
Gorgeous Cottona year ago
Avinash DV2 years ago
const solve = (strArg) => { let wordArr = strArg.split(' '); let res = []; for(let el of wordArr) { res.push(el.replace(/[^\w]/g, '')); } return res.filter(el => el!== '') };
Ali Sequeira2 years ago
Sarthak Joshi2 years ago
const solve = (strArg) => { return strArg .replace(/[^\w]/g, " ") .split(' ') .filter(space => space.trim() !== '') };
Mac Villegas2 years ago
const solve = (strArg) => { return strArg.split(/\W|\s+/g).filter(item => item !== "") };
Bryan Guilas2 years ago
Solution without using RegEx.
Coordinator proactive2 years ago
Ameliorated Tugrik2 years ago
RegExp is a powerful and succinct tool! For those participants who are looking for a course I recommend that you watch Mastering Regular Expressions in JavaScript by Steven Hancock. Believe me or not but the syntax seems to be complex or wierd. Once you pass the course - an expression like this one would be a piece of cake.
const solve = (str) => str.match(/\b\w+\b/g);
Samuel Egwurube2 years ago
The right answer
Reuven Naor2 years ago
const solve = (a) => a.split(/[^A-z^0-9]/g).filter((i) => i !== '')
redundant District3 years ago
const solve = (strArg) => { const str = strArg.replace(/[^a-zA-Z ]/g, "").split(" "); return str.filter(n => n) };
Savings Account Ergonomic3 years ago
return strArg.match(/[A-Za-z0-9]+/g);