Created
February 10, 2016 19:22
-
-
Save Fresh-Dev/1d4ea834eb2ae8b85203 to your computer and use it in GitHub Desktop.
C# RegEx Valid Mail Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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