UncleCoder.com

UncleCoder.com

Free programming examples and instructions

# Regular Expression for Email Address

## Regular expression for Email and how its work, after reading this you can write your own.

by Athil

Posted on 29 Dec 2016 Category: Javascript Views: 959

Edited on 10 Jun 2018

Expresssion

/^([a-zA-Z][a-zA-Z0-9_.%]{3,20}[@][a-zA-Z0-9_.]{2,20}[.][a-zA-Z.]{2,10})\$/

Hi, This is custom expression for internet email address. The conditions are

I Started with '[a-zA-Z]' to start with character after that u can see  '[a-zA-Z0-9_.%]{3,20}', Which means u can give characters, numbers dots(.) underscore (_) and persentage (%) symbols. with minimum 3 character and maximum of 20. If you want to cutom the characters' length,  you can change from '{3,30}'.

2. @ symbol and Dot (.) symbol is must

U can see '[@]' and '[.]' that I given for this characters are must and between this there are some parts of expresion that I used for creating second leval of domain name.
Eg:- '[email protected]'   Here gmail is the second part of domain name.

3 Use of subdomain and domain

For using subdomain I give a dot (.) in it '[a-zA-Z0-9_.]{2,20}' in domain part, The total size of domain and subdomains includding dot(.) symbols must be between 2 to 20 That I given between braces ({2,20}). If u want to change the limit u can change from there.

4 Top Level domain (Eg:- .Com)

In this expression I give  '[a-zA-Z.]{2,10}'  at the end for giving top level domain. The conditions are accept only characters and dot(.). The size must be between 2 to 10.

See some examples

Validates

[email protected]

[email protected]

[email protected]

[email protected]

[email protected]

Not validates

[email protected]   //the characters before @ must be more than 4 length

All the best

If you want more regex please comment bellow.

### Latest posts in Javascript

##### Remove items from array

#### firdouse Tuesday,22 Aug 2017

@aaa or 123 not to validate ,it must be very important

• View all

• View all

• View all