Skip to main content
added 223 characters in body
Source Link
Dharma
  • 142
  • 4

Simple Regular Expression for Email Addresses

[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}

is one of the simplest possible. In many cases this simple expression is good enough. It consists of five parts:

[A-Z0-9._%+-]+ - the first part of mail address may contain all characters, numbers, points, underscores, percent, plus and minus.

@ - the @ character is mandatory

[A-Z0-9.-]+ - the second part of mail address may contain all characters, numbers, points, underscores.

\. - the point is mandatory

[A-Z]{2,4} - the domain name may contain all characters. The number of characters is limited between 2 and 4.

OPTION 2:

^(.+)@(.+)$ 

This one is simplest and only cares about ‘@’ symbol. Before and after ‘@’ symbol, there can be any number of characters.if you want to validate point(.) add \. into regular expression.

Simple Regular Expression for Email Addresses

[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}

is one of the simplest possible. In many cases this simple expression is good enough. It consists of five parts:

[A-Z0-9._%+-]+ - the first part of mail address may contain all characters, numbers, points, underscores, percent, plus and minus.

@ - the @ character is mandatory

[A-Z0-9.-]+ - the second part of mail address may contain all characters, numbers, points, underscores.

\. - the point is mandatory

[A-Z]{2,4} - the domain name may contain all characters. The number of characters is limited between 2 and 4.

Simple Regular Expression for Email Addresses

[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}

is one of the simplest possible. In many cases this simple expression is good enough. It consists of five parts:

[A-Z0-9._%+-]+ - the first part of mail address may contain all characters, numbers, points, underscores, percent, plus and minus.

@ - the @ character is mandatory

[A-Z0-9.-]+ - the second part of mail address may contain all characters, numbers, points, underscores.

\. - the point is mandatory

[A-Z]{2,4} - the domain name may contain all characters. The number of characters is limited between 2 and 4.

OPTION 2:

^(.+)@(.+)$ 

This one is simplest and only cares about ‘@’ symbol. Before and after ‘@’ symbol, there can be any number of characters.if you want to validate point(.) add \. into regular expression.

Source Link
Dharma
  • 142
  • 4

Simple Regular Expression for Email Addresses

[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}

is one of the simplest possible. In many cases this simple expression is good enough. It consists of five parts:

[A-Z0-9._%+-]+ - the first part of mail address may contain all characters, numbers, points, underscores, percent, plus and minus.

@ - the @ character is mandatory

[A-Z0-9.-]+ - the second part of mail address may contain all characters, numbers, points, underscores.

\. - the point is mandatory

[A-Z]{2,4} - the domain name may contain all characters. The number of characters is limited between 2 and 4.