IOS determines whether expression and email format are used
1. This method is displayed on the Forum. It is quite helpful to use it. Please forget it here !!!!!
2. In the application environment, you cannot enter an expression when entering a nickname.
-(BOOL) stringContainsEmoji :( NSString *) string {
_ BlockBOOL returnValue = NO;
[String enumerateSubstringsInRange: NSMakeRange (0, [stringlength]) options: NSStringEnumerationByComposedCharacterSequencesusingBlock:
^ (NSString * substring, nsange substringRange, nsange enclosingRange, BOOL * stop ){
Constunichar hs = [substringcharacterAtIndex: 0];
// Surrogate pair
If (0xd800 <= hs & hs <= 0 xdbff ){
If (substring. length> 1 ){
Constunichar ls = [substringcharacterAtIndex: 1];
Constint uc = (hs-0xd800) * 0x400) + (ls-0xdc00) + 0x10000;
If (0x1d000 <= uc & uc <= 0x1f77f ){
ReturnValue = YES;
}
}
} Elseif (substring. length> 1 ){
Constunichar ls = [substringcharacterAtIndex: 1];
If (ls = 0x20e3 ){
ReturnValue = YES;
}
} Else {
// Non surrogate
If (0x2100 <= hs & hs <= 0x27ff ){
ReturnValue = YES;
} Elseif (0x2B05 <= hs & hs <= 0x2b07 ){
ReturnValue = YES;
} Elseif (0x2934 <= hs & hs <= 0x2935 ){
ReturnValue = YES;
} Elseif (0x3297 <= hs & hs <= 0x3299 ){
ReturnValue = YES;
} Elseif (hs = 0xa9 | hs = 0xae | hs = 0x303d | hs = 0x3030 | hs = 0x2b55 | hs = 0x2b1c | | hs = 0x2b1b | hs = 0x2b50) {
ReturnValue = YES;
}
}
}];
Return returnValue;
}
// Email Interpretation
// Determine whether the email format is correct.
-(BOOL) isValidateEmail :( NSString *) email
{
NSString * emailRegex = @ "[A-Z0-9a-z. _ % +-] + @ [A-Za-z0-9.-] + \. [A-Za-z] {2, 4 }";
NSPredicate * emailTest = [NSPredicatepredicateWithFormat: @ "self matches % @", emailRegex];
Return [emailTest evaluateWithObject: email];
}