Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSRegularExpression validate email

Tags:

People also ask

Can email be validated with regex?

Regex provides the ability to validate the structure of an email address. It can be handled with one or two lines of code and can easily be tweaked to handle a wide variation of different parameters.

How do I validate an email format?

A valid email address consists of an email prefix and an email domain, both in acceptable formats. The prefix appears to the left of the @ symbol. The domain appears to the right of the @ symbol. For example, in the address [email protected], "example" is the email prefix, and "mail.com" is the email domain.

How do I validate an email in Swift?

Three Methods to Validate Email in SwiftUsing functions of Swift NSPredicate class to match an email address input with a regular expression. Creating a custom class conforming to RawRepresentable which initializes only if a valid email address is provided.


i want to use the NSRegularExpression Class to validate if an NSString is an email address.

Something like this pseudocode:

- (BOOL)validateMail : (NSString *)email
{
    NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:@"" options:NSRegularExpressionCaseInsensitive error:NULL];

    if(emailValidated)
    {
        return YES;
    }else{
        return NO;
    }
}

But i don't know how exactly i validate an NSString if it's looking like this one "[email protected]"

Perhaps someone can help me here.

Greetings s4lfish