import UIKit
class Regular: NSObject {
/*
+ (BOOL)regular_Phone:(NSString *)Phone
{
NSString *pattern = @"^1+[13456789]+\\d{9}";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
BOOL isMatch = [pred evaluateWithObject:Phone];
return isMatch;
}
*/
///加@objc 为了方便OC类调用
@objc func regular_Phone(Phone : String) -> Bool {
let pattern = "^1+[13456789]+\\d{9}";
let pred = NSPredicate.init(format: "SELF MATCHES %@", pattern);
let isResult = pred.evaluate(with: Phone);
return isResult;
}
}
网友评论