web analytics
Regular Expressions in C# Options
codeling
Posted: Friday, September 29, 2017 1:35:19 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 892
Points: 3738

Validating email format using regular expression in C#

The following code example uses the static Regex.IsMatch method and a regular expression to verify that a string is in valid e-mail format.

bool IsValidEmail(string strIn)

{

     // Return true if strIn is in valid e-mail format.

     return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");

}

Sponsor
Posted: Friday, September 29, 2017 1:35:19 PM
Users browsing this topic
Guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


© 2017 Digcode.com. All rights reserved.