Guest User

Untitled

a guest
Jun 4th, 2018
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. bool valid = true;
  2. try
  3. {
  4. MailAddress address = new MailAddress(email);
  5. }
  6. catch(FormatException)
  7. {
  8. valid = false;
  9. }
  10.  
  11. if(!(email.EndsWith("@home.co.uk") ||
  12. email.EndsWith("@home.com") ||
  13. email.EndsWith("@homegroup.com")))
  14. {
  15. valid = false;
  16. }
  17.  
  18. return valid;
  19.  
  20. ^[A-Z0-9._%+-]+((@home.co.uk)|(@home.com)|(@homegroup.com))$
  21.  
  22. string emailAddress = "jim@home.com";
  23. string pattern = @"^[A-Z0-9._%+-]+((@home.co.uk)|(@home.com)|(@homegroup.com))$";
  24. if (Regex.IsMatch(emailAddress, pattern, RegexOptions.IgnoreCase))
  25. {
  26. // email address is valid
  27. }
  28.  
  29. Dim emailAddress As String = "jim@home.com"
  30. Dim pattern As String = "^[A-Z0-9._%+-]+((@home.co.uk)|(@home.com)|(@homegroup.com))$";
  31. If Regex.IsMatch(emailAddress, pattern, RegexOptions.IgnoreCase) Then
  32. ' email address is valid
  33. End If
  34.  
  35. (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[x01-x08x0bx0cx0e-x1fx21x23-x5bx5d-x7f]|\[x01-x09x0bx0cx0e-x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[x01-x08x0bx0cx0e-x1fx21-x5ax53-x7f]|\[x01-x09x0bx0cx0e-x7f])+)])
  36.  
  37. [A-Z0-9._%+-]+@home(.co.uk|(group)?.com)
  38.  
  39. "[A-Z0-9._%+-]+@home(\.co\.uk|(group)?\.com)"
  40.  
  41. Regex matcher = new Regex(@"([a-zA-Z0-9_-.]+)@((home.co.uk)|(home.com)|(homegroup.com))");
  42.  
  43. if(matcher.IsMatch(theEmailAddressToCheck))
  44. {
  45. //Allow it
  46. }
  47. else
  48. {
  49. //Don't allow it
  50. }
  51.  
  52. using System.Text.RegularExpressions;
  53.  
  54. public static bool ValidEmail(this string email)
  55. {
  56. var emailregex = new Regex(@"[A-Za-z0-9._%-]+(@home.co.uk$)|(@home.com$)|(@homegroup.com$)");
  57. var match = emailregex.Match(email);
  58. return match.Success;
  59. }
  60.  
  61. string emailAddress = "someone@home.co.uk";
  62. if (Regex.IsMatch(emailAddress, @"^[A-Z0-9._%+-]+@home(?:.co.uk|(?:group)?.com)$", RegexOptions.IgnoreCase))
  63. {
  64. // email address is valid
  65. }
  66.  
  67. string emailAddress = "someone@home.co.uk";
  68. if (Regex.IsMatch(emailAddress, @"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@home(?:.co.uk|(?:group)?.com)$", RegexOptions.IgnoreCase))
  69. {
  70. // email address is valid
  71. }
Add Comment
Please, Sign In to add comment