限制汉字长度

NSString * ISNAME = @"^[\u4E00-\u9FA5]{2,4}$";   //2-4个汉字
NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", ISNAME];
if ([regextestmobile evaluateWithObject:_tf2_xingming.text] == NO)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告" message:@"请输入正确的姓名" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}

posted @ 2015-03-26 17:33  lol挂  阅读(145)  评论(0)    收藏  举报