Question

In my application I validate emails; but we can give more than one email address separated with a semicolon (";"). How can I write the validation expression?

My emails look like this:

"sasidhar@yahoo.com;suryasasidhar@gmail.com;srinivas@gmail.com "

How can I write a regular expression for this?

Was it helpful?

Solution

You can give this a try:

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*

This is from RegexLib.com

OTHER TIPS

Start with the basic email regex and then apply as follows:

<email regex>(;<email regex>)*
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top