Email validation on textField in iOS

Use NSPredicate and Regex: – (BOOL)validateEmailWithString:(NSString*)email { NSString *emailRegex = @”[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}”; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@”SELF MATCHES %@”, emailRegex]; return [emailTest evaluateWithObject:email]; } For a bunch of emails separated by a comma: – (NSMutableArray*)validateEmailWithString:(NSString*)emails { NSMutableArray *validEmails = [[NSMutableArray alloc] init]; NSArray *emailArray = [emails componentsSeparatedByString:@”,”]; for (NSString *email in emailArray) { NSString *emailRegex = … Read more

PHP email validation [duplicate]

I suggest you use the FILTER_VALIDATE_EMAIL filter: if (filter_var($email, FILTER_VALIDATE_EMAIL)) { //valid } You can also use its regular expression directly: “/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD” But in that case, if a bug is found in the regular expression, you’ll have to update your program instead of just updating PHP.

How to block Disposable Email Addresses in your website’s registration form? [closed]

This is tough, because neither whitelisting nor blacklisting are an option. By whitelisting certain domains, you disallow people with email domains that are unknown to you (but might be perfectly valid), while by blacklisting you have to update the list of blacklisted domains on a daily basis, since new “10 minute email” domains emerge every … Read more

Generating confirmation code for an email confirmation

$random_hash = md5(uniqid(rand(), true)); That will be 32 alphanumeric characters long and unique. If you want it to be shorter just use substr(): $random_hash = substr(md5(uniqid(rand(), true)), 16, 16); // 16 characters long Alternative methods to generate random data include: $random_hash = md5(openssl_random_pseudo_bytes(32)); $random_hash = md5(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM)); // New in PHP7 $random_hash = bin2hex(random_bytes(32));

Check that an email address is valid on iOS [duplicate]

Good cocoa function: -(BOOL) NSStringIsValidEmail:(NSString *)checkString { BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ NSString *stricterFilterString = @”^[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}$”; NSString *laxString = @”^.+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*$”; NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@”SELF MATCHES %@”, emailRegex]; return [emailTest evaluateWithObject:checkString]; } Discussion on Lax vs. Strict – http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ And because categories are just better, … Read more

Email validation using regular expression in JSF 2 / PrimeFaces

All regular expression attempts to validate the email format based on Latin characters are broken. They do not support internationalized domain names which were available since May 2010. Yes, you read it right, non-Latin characters are since then allowed in domain names and thus also email addresses. That are thus extremely a lot of possible … Read more