Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MarcVanH

macrumors newbie
Original poster
Sep 12, 2008
15
0
I thought I had found a great bit of code for validating an email address using regular expressions,

Code:
- (BOOL)isValidEmail:(NSString*)myEmail 
{
	NSString *emailRegEx = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; 
	NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegEx]; 
	//Valid email address 
	return ([emailTest evaluateWithObject:myEmail]) ;
}

But then I found out NSPredicate does not work on the phone (only the simulator).

Has anyone by chance written working code to validate an email address on the iPhone?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.