Sunday 15 July 2012

regex - Split substrings within a string in C# -



regex - Split substrings within a string in C# -

i need check string contains list of e-mails. these emails separated commas, need check if somewhere in list there delimiter other comma. here's example:

email1@email.com,email2@email.com,email3@email.com#email4@email.com

i need identify different character , replace comma.

i cannot utilize regex identify special characters other comma , replace them because emails may have of these characters. need find between 2 e-mail. made next regex identify e-mail , believe cover of emails:

^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-z0-9]+(\.[a-z0-9]+)+$

but i'm little lost on how utilize solve problem, using c #. need capture between 2 matches of regex , replace comma.

could help me? give thanks you.

([^@,]+@[^.]+\.\w{3}(?!,|$)).

try this.replace $1,.see demo.

http://regex101.com/r/tf4jd3/15

p.s work email id's of format something@something.com.

c# regex string email

No comments:

Post a Comment