Skip to content

Instantly share code, notes, and snippets.

@Fresh-Dev
Created February 10, 2016 19:22
Show Gist options
  • Save Fresh-Dev/1d4ea834eb2ae8b85203 to your computer and use it in GitHub Desktop.
Save Fresh-Dev/1d4ea834eb2ae8b85203 to your computer and use it in GitHub Desktop.
C# RegEx Valid Mail Check
/*Regex Tester: version=1.4.2.0
----------------------------------------
REGEX MODE: Match
REGEX OPTIONS: Singleline
INPUT REGEX: ^[\w-\._\+%]+@(?:[\w-]+\.)+[\w]{2,6}$
INPUT FORMAT:
-----INPUT TEXT-----------------------------------
[email protected]
-----OUTPUT TEXT-----------------------------------*/
string pattern = @"^[\w-\._\+%]+@(?:[\w-]+\.)+[\w]{2,6}$";
RegexOptions regexOptions = RegexOptions.Singleline;
Regex regex = new Regex(pattern, regexOptions);
string inputData = @"[email protected]";
foreach (Match match in regex.Matches(inputData))
{
if (match.Success)
{
//TODO processing results
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment