ios NSString 截取汉字 数字 字母

字符串截取:

删除字符串中的字母+汉字

NSString *string = @"bushi1222真正90-快乐";

NSRegularExpression *regular = [NSRegularExpression regularExpressionWithPattern:@"[a-zA-Z\u4e00-\u9fa5]+" options:0 error:NULL];

result = [regular stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:@""];

result 即为截取后的结果。

字符串替换:

result = [result stringByReplacingOccurrencesOfString:@"(null)" withString:@""];

 

posted @ 2016-05-26 18:28  fantasy_love  阅读(2276)  评论(0编辑  收藏  举报