var email = "your@email.com";
Regex regex = new Regex(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
+ "@"
+ @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$");
Match match = regex.Match(email);
if (match.Success)
Console.Write("correct");
for phone number use the pattern:
string pattern = @"
^ # From Beginning of line
(?:\(?) # Match but don't capture optional (
(?<areacode>\d{3}) # 3 digit area code
(?:[\).]?) # Optional ) or .
(?<prefix>\d{3}) # Prefix
(?:[-\.]?) # optional - or .
(?<suffix>\d{4}) # Suffix
(?!\d) # Fail if eleventh number found";
</suffix></prefix></areacode>
Source[
^]