dagda1
dagda1

Reputation: 28820

regex to stop name part of email being all numbers

I have the following email regex which I got from stackoverflow:

/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()\.,;\s@\"]+\.{0,1})+[^<>()\.,;:\s@\"]{2,})$/

We want to fail all email addresses that are of this form:

[email protected].

How could I update the regex to cover this case?

Upvotes: 0

Views: 40

Answers (1)

guest271314
guest271314

Reputation: 1

You can check if the beginning of the string are digit characters followed by "@" character

// returns `false` if match is found
!/^\d+(?=@)/.test("[email protected]") && /* other `RegExp`s */

Upvotes: 2

Related Questions