Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: \w+ not working in regex validation #9

Open
gwenf opened this issue Mar 8, 2020 · 2 comments
Open

Bug: \w+ not working in regex validation #9

gwenf opened this issue Mar 8, 2020 · 2 comments

Comments

@gwenf
Copy link
Collaborator

gwenf commented Mar 8, 2020

Why is this not considered valid regex?

@SamiiS
Copy link

SamiiS commented Mar 25, 2020

Correct: https?://(?!www)([a-z0-9]+[.])\\w+[.]com
Yours: https?://(?!www)([a-z0-9]+[.])\w+[.]com

Cause: \w gets escaped into just w. You'll want it to be \w therefor \\w.

If you don't use it already, use ESLint, it'll tell you about this! :)

@SamiiS
Copy link

SamiiS commented Mar 25, 2020

Correct: https?://(?!www)([a-z0-9]+[.])\\w+[.]com
Yours: https?://(?!www)([a-z0-9]+[.])\w+[.]com

Cause: \w gets escaped into just w. You'll want it to be \w therefor \w.

If you don't use it already, use ESLint, it'll tell you about this! :)

And this would in turn fix it so the userRegex will match the solutionRegex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants