Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool valid = true;
- try
- {
- MailAddress address = new MailAddress(email);
- }
- catch(FormatException)
- {
- valid = false;
- }
- if(!(email.EndsWith("@home.co.uk") ||
- email.EndsWith("@home.com") ||
- email.EndsWith("@homegroup.com")))
- {
- valid = false;
- }
- return valid;
- ^[A-Z0-9._%+-]+((@home.co.uk)|(@home.com)|(@homegroup.com))$
- string emailAddress = "jim@home.com";
- string pattern = @"^[A-Z0-9._%+-]+((@home.co.uk)|(@home.com)|(@homegroup.com))$";
- if (Regex.IsMatch(emailAddress, pattern, RegexOptions.IgnoreCase))
- {
- // email address is valid
- }
- Dim emailAddress As String = "jim@home.com"
- Dim pattern As String = "^[A-Z0-9._%+-]+((@home.co.uk)|(@home.com)|(@homegroup.com))$";
- If Regex.IsMatch(emailAddress, pattern, RegexOptions.IgnoreCase) Then
- ' email address is valid
- End If
- (?:[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])+)])
- [A-Z0-9._%+-]+@home(.co.uk|(group)?.com)
- "[A-Z0-9._%+-]+@home(\.co\.uk|(group)?\.com)"
- Regex matcher = new Regex(@"([a-zA-Z0-9_-.]+)@((home.co.uk)|(home.com)|(homegroup.com))");
- if(matcher.IsMatch(theEmailAddressToCheck))
- {
- //Allow it
- }
- else
- {
- //Don't allow it
- }
- using System.Text.RegularExpressions;
- public static bool ValidEmail(this string email)
- {
- var emailregex = new Regex(@"[A-Za-z0-9._%-]+(@home.co.uk$)|(@home.com$)|(@homegroup.com$)");
- var match = emailregex.Match(email);
- return match.Success;
- }
- string emailAddress = "someone@home.co.uk";
- if (Regex.IsMatch(emailAddress, @"^[A-Z0-9._%+-]+@home(?:.co.uk|(?:group)?.com)$", RegexOptions.IgnoreCase))
- {
- // email address is valid
- }
- string emailAddress = "someone@home.co.uk";
- if (Regex.IsMatch(emailAddress, @"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@home(?:.co.uk|(?:group)?.com)$", RegexOptions.IgnoreCase))
- {
- // email address is valid
- }
Add Comment
Please, Sign In to add comment