Regex for email address

前端 未结 4 1864
后悔当初
后悔当初 2020-12-29 23:13

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条回答
  •  一生所求
    2020-12-30 00:15

    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;
        
          }
    

提交回复
热议问题