Skip to content

Commit

Permalink
优化正则判断新号码的更新
Browse files Browse the repository at this point in the history
  • Loading branch information
boai committed Jan 22, 2017
1 parent 8401efa commit 6761267
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
12 changes: 6 additions & 6 deletions BABaseProject.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
C4309BBF1DCAD5C40016ABE6 /* UIViewController+BAHook.m in Sources */ = {isa = PBXBuildFile; fileRef = C4309BBB1DCAD5C40016ABE6 /* UIViewController+BAHook.m */; };
C430AB761CDC8A360086DDD6 /* DemoVC3.m in Sources */ = {isa = PBXBuildFile; fileRef = C430AB751CDC8A360086DDD6 /* DemoVC3.m */; };
C43222D41DC9D18800AE63F2 /* AppDelegate+BAUMengAnalytics.m in Sources */ = {isa = PBXBuildFile; fileRef = C43222D31DC9D18800AE63F2 /* AppDelegate+BAUMengAnalytics.m */; };
C432E6031E3490D600463558 /* BARegularExpression.m in Sources */ = {isa = PBXBuildFile; fileRef = C432E6021E3490D600463558 /* BARegularExpression.m */; };
C44423341D2E7775004ACAA8 /* BABaseHeaderFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = C44423331D2E7775004ACAA8 /* BABaseHeaderFooterView.m */; };
C44423491D2E85B8004ACAA8 /* DemoVC2_02.m in Sources */ = {isa = PBXBuildFile; fileRef = C44423481D2E85B8004ACAA8 /* DemoVC2_02.m */; };
C444234C1D2E8680004ACAA8 /* DemoVC2_02_HeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = C444234B1D2E8680004ACAA8 /* DemoVC2_02_HeaderView.m */; };
Expand Down Expand Up @@ -242,7 +243,6 @@
C4C744391DC72DB300E747D8 /* BALocalNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = C4C743911DC72DB300E747D8 /* BALocalNotification.m */; };
C4C7443A1DC72DB300E747D8 /* BACustomBarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C4C743941DC72DB300E747D8 /* BACustomBarItem.m */; };
C4C7443B1DC72DB300E747D8 /* UINavigationItem+CustomItem.m in Sources */ = {isa = PBXBuildFile; fileRef = C4C743961DC72DB300E747D8 /* UINavigationItem+CustomItem.m */; };
C4C7443C1DC72DB300E747D8 /* BARegularExpression.m in Sources */ = {isa = PBXBuildFile; fileRef = C4C743991DC72DB300E747D8 /* BARegularExpression.m */; };
C4C7443D1DC72DB300E747D8 /* HMSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = C4C7439C1DC72DB300E747D8 /* HMSegmentedControl.m */; };
C4C7443E1DC72DB300E747D8 /* BAShareAnimationView.m in Sources */ = {isa = PBXBuildFile; fileRef = C4C7439F1DC72DB300E747D8 /* BAShareAnimationView.m */; };
C4C7443F1DC72DB300E747D8 /* BAShareManage.m in Sources */ = {isa = PBXBuildFile; fileRef = C4C743A11DC72DB300E747D8 /* BAShareManage.m */; };
Expand Down Expand Up @@ -556,6 +556,8 @@
C430AB751CDC8A360086DDD6 /* DemoVC3.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoVC3.m; sourceTree = "<group>"; };
C43222D21DC9D18800AE63F2 /* AppDelegate+BAUMengAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+BAUMengAnalytics.h"; sourceTree = "<group>"; };
C43222D31DC9D18800AE63F2 /* AppDelegate+BAUMengAnalytics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+BAUMengAnalytics.m"; sourceTree = "<group>"; };
C432E6011E3490D600463558 /* BARegularExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BARegularExpression.h; sourceTree = "<group>"; };
C432E6021E3490D600463558 /* BARegularExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BARegularExpression.m; sourceTree = "<group>"; };
C44423321D2E7775004ACAA8 /* BABaseHeaderFooterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BABaseHeaderFooterView.h; sourceTree = "<group>"; };
C44423331D2E7775004ACAA8 /* BABaseHeaderFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BABaseHeaderFooterView.m; sourceTree = "<group>"; };
C44423471D2E85B8004ACAA8 /* DemoVC2_02.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoVC2_02.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -808,8 +810,6 @@
C4C743941DC72DB300E747D8 /* BACustomBarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BACustomBarItem.m; sourceTree = "<group>"; };
C4C743951DC72DB300E747D8 /* UINavigationItem+CustomItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationItem+CustomItem.h"; sourceTree = "<group>"; };
C4C743961DC72DB300E747D8 /* UINavigationItem+CustomItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationItem+CustomItem.m"; sourceTree = "<group>"; };
C4C743981DC72DB300E747D8 /* BARegularExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BARegularExpression.h; sourceTree = "<group>"; };
C4C743991DC72DB300E747D8 /* BARegularExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BARegularExpression.m; sourceTree = "<group>"; };
C4C7439B1DC72DB300E747D8 /* HMSegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMSegmentedControl.h; sourceTree = "<group>"; };
C4C7439C1DC72DB300E747D8 /* HMSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMSegmentedControl.m; sourceTree = "<group>"; };
C4C7439E1DC72DB300E747D8 /* BAShareAnimationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BAShareAnimationView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2310,8 +2310,8 @@
C4C743971DC72DB300E747D8 /* BARegularExpression */ = {
isa = PBXGroup;
children = (
C4C743981DC72DB300E747D8 /* BARegularExpression.h */,
C4C743991DC72DB300E747D8 /* BARegularExpression.m */,
C432E6011E3490D600463558 /* BARegularExpression.h */,
C432E6021E3490D600463558 /* BARegularExpression.m */,
);
path = BARegularExpression;
sourceTree = "<group>";
Expand Down Expand Up @@ -3846,6 +3846,7 @@
C4C7444B1DC72DB300E747D8 /* NSDateFormatter+BAKit.m in Sources */,
C44C00D31DCB30BA00BAAAEC /* UIButton+BAHook.m in Sources */,
C46B8A041CE0BAC200005E2B /* RegexKitLite.m in Sources */,
C432E6031E3490D600463558 /* BARegularExpression.m in Sources */,
C4EB5AA81CD8B04B003A7094 /* AppDelegate.m in Sources */,
C4C744771DC72DB300E747D8 /* UIView+BAKit.m in Sources */,
C4F59F8A1D54684E00AA822A /* BAADScrollView.m in Sources */,
Expand Down Expand Up @@ -3995,7 +3996,6 @@
C4C744841DC7306800E747D8 /* DemoVC2_05_test.m in Sources */,
C4DEB37A1D0C3351001F1585 /* BATabBar2.m in Sources */,
C473CC811CF72960001883A9 /* DemoVC9_Model.m in Sources */,
C4C7443C1DC72DB300E747D8 /* BARegularExpression.m in Sources */,
C4C744441DC72DB300E747D8 /* BACustomMJFooter.m in Sources */,
C48026C91D191EC90087BBB9 /* DemoVC11_Cell.m in Sources */,
C40852BC1CDA09100004A671 /* DemoVC2.m in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ - (void)didReceiveMemoryWarning {
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@
*
* 在使用BAKit的过程中如果出现bug请及时以以下任意一种方式联系我,我会及时修复bug
*
* QQ : 可以添加SDAutoLayout群 497140713 在这里找到我(博爱1616【137361770】)
* QQ : 可以添加ios开发技术群 479663605 在这里找到我(博爱1616【137361770】)
* 微博 : 博爱1616
* Email : [email protected]
* GitHub : https://github.com/boai
* 博客园 : http://www.cnblogs.com/boai/
* 博客 : http://boai.github.io
* 博客 : http://boaihome.com
*********************************************************************************
*/

/*!
最新更新时间:2017-1-22 【倒叙】
最新Version:【Version:2.0.1】
更新内容:
2.0.1.1、新增170、172、175、176、177、178等新增号段的验证
最新更新时间:2016-11-17 【倒叙】
最新Version:【Version:2.0】
更新内容:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ @implementation BARegularExpression
#pragma mark - ***** 是否为电话号码【简单写法】
+(BOOL)ba_isPhoneNumber:(NSString *)phoneNum
{
NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|8[0-9]|70)\\d{8}$";
NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|7[01235678]|8[0-9])\\d{8}$";
NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
return [regextestmobile evaluateWithObject:phoneNum];
}
Expand All @@ -79,27 +79,27 @@ + (BOOL)ba_isMobileNumber:(NSString *)mobileNum
}
/**
* 手机号码:
* 13[0-9], 14[5,7], 15[0, 1, 2, 3, 5, 6, 7, 8, 9], 17[6, 7, 8], 18[0-9], 170[0-9]
* 移动号段: 134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705
* 联通号段: 130,131,132,155,156,185,186,145,176,1709
* 电信号段: 133,153,180,181,189,177,1700
* 13[0-9], 14[5,7], 15[0, 1, 2, 3, 5, 6, 7, 8, 9], 17[0, 1, 6, 7, 8], 18[0-9]
* 移动号段: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188
* 联通号段: 130,131,132,145,155,156,170,171,172,175,176,185,186
* 电信号段: 133,149,153,170,173,177,180,181,189
*/
NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|8[0-9]|70)\\d{8}$";
NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$";
/**
* 中国移动:China Mobile
* 134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705
* 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188
*/
NSString *CM = @"(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)";
NSString *CM = @"(^1(3[4-9]|4[7]|5[0-27-9]|7[08]|8[2-478])\\d{8}$";
/**
* 中国联通:China Unicom
* 130,131,132,155,156,185,186,145,176,1709
* 130,131,132,145,155,156,170,171,172,175,176,185,186
*/
NSString *CU = @"(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^1709\\d{7}$)";
NSString *CU = @"(^1(3[0-2]|4[5]|5[56]|701256||8[56])\\d{8}$";
/**
* 中国电信:China Telecom
* 133,153,180,181,189,177,1700
* 133,149,153,170,173,177,180,181,189
*/
NSString *CT = @"(^1(33|53|77|8[019])\\d{8}$)|(^1700\\d{7}$)";
NSString *CT = @"^1(3[3]|4[9]|53|7[037]|8[019])\\d{8}$";


NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
Expand Down

0 comments on commit 6761267

Please sign in to comment.