1. The method is seen from the forum, the use of their own under the feeling is very useful, do a memo here!!!!!
2. Application environment, when the user enters the nickname, can not enter the expression
-(BOOL) Stringcontainsemoji: (nsstring *) string {
__block BOOL returnvalue =NO;
[String enumeratesubstringsinrange:nsmakerange(0, [stringlength])options :nsstringenumerationbycomposedcharactersequencesusingblock:
^ (nsstring *substring,nsrange substringrange,nsrange enclosingrange, BOOL *stop ) {
Const Unichar hs = [substringcharacteratindex: 0];
//surrogate pair
if (0xd800 <= HS && HS <= 0XDBFF) {
if (substring. length > 1) {
Const unichar ls = [substringcharacteratindex: 1];
Const int UC = ((hs-0xd800) * 0x400) + (LS-0XDC00) + 0x10000;
if (0x1d000 <= UC && UC <= 0x1f77f) {
returnvalue =YES;
}
}
}Elseif (substring. Length > 1) {
Const unichar 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;
}
E-Mail interpretation
Determine if it is a mailbox format
-(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];
}
iOS to determine whether the expression and mailbox format are judged