Regex for email address

Viewed 15840

Can someone show me a sample RegEx for an email address and how to use in in Objective-C?

Looking for something that fits: name@place.something

4 Answers

Regular expression for Invalid email format:

public static bool IsEmailValid(this string inputStr)
  {
    bool isValid = false;
    if (!string.IsNullOrWhiteSpace(inputStr))
     {
  isValid  = Regex.IsMatch(inputStr, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", 
                                    RegexOptions.IgnoreCase);
       }
    
         return isValid;
    
      }
Related