Regular expression for allow multiple email ids

Posted by Lakkilakki under ASP.NET on 9/6/2012 | Points: 10 | Views : 1288 | Status : [Member] | Replies : 3
Regular expression for allow multiple email ids separated by comma,should not allow multiple commas at the end and in between two email ids.


My regular expression for allow multiple email id's is:
((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*

But it is allowing multiple commas at the end of the email id and inbetween two email ids
For ex:

**test@abc.com,,test2@abc.com,,**

it should not happend..

Thanks In advance,
Lakki




Responses

Posted by: Sakthi.Singaravel on: 9/7/2012 [Member] Silver | Points: 25

Up
0
Down
((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)([,])?)+

Regards,
Singaravel M

Lakkilakki, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijay.K on: 9/7/2012 [Member] Starter | Points: 25

Up
0
Down
You can split your email-var on a ",", and check for each email address you got

vijay.k

Lakkilakki, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijay.K on: 9/7/2012 [Member] Starter | Points: 25

Up
0
Down
"((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*"

vijay.k

Lakkilakki, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response