Shannon Hochkins
Shannon Hochkins

Reputation: 12175

Validate email with RegEx following rules

Needs to only contain [a-zA-Z0-9.], and followed by an @ then the same match afterward, the match before, and after the @ shouldn't be any longer than 64 characters long, and at least one length.

^([a-zA-Z0-9\-\.]+){1,64}@([a-zA-Z0-9\-\.]){1,64}$

This seems to work but it sometimes takes forever, why is this?

Upvotes: 1

Views: 105

Answers (2)

JuanCrg90
JuanCrg90

Reputation: 1016

I'm not sure why you have the + operator in the first part of the regex. I hope this could be useful for you

^([a-zA-Z\d\.]{1,64})@([a-zA-Z\d\.]{1,64})$

Upvotes: 1

Dim
Dim

Reputation: 3

For email regex you should use http://emailregex.com/ which provides this regex

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

also, if you can you should usually just use

<input type="email">

Upvotes: 0

Related Questions