Solved: Is there something wrong with const emailRegex = /[\w\.-]+@[\w\._-]+\.[a-zA-Z]{2,4}+/; that I just don’t see?
Still struggling with regex! I’m getting the following error message when creating a JS regex variable:
ESLint found 1 issue:
const emailRegex = /[\w\.-]+@[\w\._-]+\.[a-zA-Z]{2,4}+/;
Parsing error: Invalid regular expression: /[\w\.-]+@[\w\._-]+\.[a-zA-Z]{2,4}+/: Nothing to repeat (This location is where the parser gave up trying to understand your malformed JavaScript. The actual error may be somewhere else.)
In the error, the first [ is highlighted in red.
I’ve tried using ( instead of [ ; and adding ^ $ anchors, and escaping the \ characters without any effect, The regex checks out OK using an online validator. I’m hoping this is just a typical rookie mistake.
Read more here: Source link
