├── MitCheckDemo ├── .DS_Store ├── MitCheckDemo │ ├── .DS_Store │ ├── MitRegex.zip │ ├── MitRegex │ │ ├── MitRegex.h │ │ ├── NSObject+mitRegexMaker.h │ │ ├── MitRegexConst.m │ │ ├── NSObject+mitRegexMaker.m │ │ ├── MitRegexConst.h │ │ ├── MitRegexMaker.h │ │ └── MitRegexMaker.m │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ ├── ViewController.m │ └── AppDelegate.m └── MitCheckDemo.xcodeproj │ ├── xcuserdata │ ├── mengchen.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ ├── xcschememanagement.plist │ │ │ └── MitCheckDemo.xcscheme │ └── william.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── MitCheckDemo.xcscheme │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcuserdata │ │ ├── william.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ └── mengchen.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── MitCheckDemo.xcscmblueprint │ └── project.pbxproj ├── MitRegx ├── 0.0.1 │ └── MitRegx.podspec └── 0.0.3 │ └── MitRegx.podspec ├── LICENSE └── README.md /MitCheckDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitchell-dream/MitRegx/HEAD/MitCheckDemo/.DS_Store -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitchell-dream/MitRegx/HEAD/MitCheckDemo/MitCheckDemo/.DS_Store -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitchell-dream/MitRegx/HEAD/MitCheckDemo/MitCheckDemo/MitRegex.zip -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex/MitRegex.h: -------------------------------------------------------------------------------- 1 | 2 | #import "MitRegexConst.h" 3 | #import "MitRegexMaker.h" 4 | #import "NSObject+mitRegexMaker.h" 5 | 6 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/xcuserdata/mengchen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/xcuserdata/william.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/project.xcworkspace/xcuserdata/william.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitchell-dream/MitRegx/HEAD/MitCheckDemo/MitCheckDemo.xcodeproj/project.xcworkspace/xcuserdata/william.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/project.xcworkspace/xcuserdata/mengchen.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mitchell-dream/MitRegx/HEAD/MitCheckDemo/MitCheckDemo.xcodeproj/project.xcworkspace/xcuserdata/mengchen.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MitCheckDemo 4 | // 5 | // Created by MENGCHEN on 15/12/3. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MitCheckDemo 4 | // 5 | // Created by MENGCHEN on 15/12/3. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MitCheckDemo 4 | // 5 | // Created by MENGCHEN on 15/12/3. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MitRegx/0.0.1/MitRegx.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = 'MitRegx' 4 | s.version = '0.0.1' 5 | s.summary = 'MitRegx' 6 | s.homepage = 'https://github.com/mcmengchen' 7 | s.license = 'MIT' 8 | s.authors = {'mcmengchen' => '416922992@qq.com'} 9 | s.platform = :ios, '7.0' 10 | s.source = {:git => 'https://github.com/mcmengchen/MitRegx.git', :tag => s.version} 11 | s.source_files = 'MitCheckDemo/MitCheckDemo/MitRegex/*.{h,m}' 12 | s.frameworks = 'UIKit', 'Foundation' 13 | s.requires_arc = true 14 | end 15 | -------------------------------------------------------------------------------- /MitRegx/0.0.3/MitRegx.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = 'MitRegx' 4 | s.version = '0.0.3' 5 | s.summary = 'MitRegx' 6 | s.homepage = 'https://github.com/mcmengchen' 7 | s.license = 'MIT' 8 | s.authors = {'mcmengchen' => '416922992@qq.com'} 9 | s.platform = :ios, '7.0' 10 | s.source = {:git => 'https://github.com/mcmengchen/MitRegx.git', :tag => s.version} 11 | s.source_files = 'MitCheckDemo/MitCheckDemo/MitRegex/*.{h,m}' 12 | s.frameworks = 'UIKit', 'Foundation' 13 | s.requires_arc = true 14 | end 15 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/xcuserdata/mengchen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MitCheckDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FCA080231C1066DC00E829B3 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/xcuserdata/william.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MitCheckDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FCA080231C1066DC00E829B3 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex/NSObject+mitRegexMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+mitRegexMaker.h 3 | // ReactiveCocoaDe 4 | // 5 | // Created by MENGCHEN on 15/11/15. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MitRegexMaker.h" 11 | @interface NSObject (mitRegexMaker) 12 | 13 | /** 获取处理类 */ 14 | + (MitRegexMaker*)mit_makeMitRegexMaker:(void(^)(MitRegexMaker * maker))block; 15 | 16 | /** 17 | * 状态码 + 状态码信息 (Block) 18 | * @param block 校验处理类 19 | * @param mitBlock 返回状态值信息(只有当校验状态全部通过的时候, isPassed 才返回 Yes) 20 | */ 21 | + (void)mit_makeMitRegexMaker:(void(^)(MitRegexMaker * maker))block MitValue:(void(^)(MitRegexStateType statusType,NSString * statusStr,BOOL isPassed))mitBlock; 22 | 23 | /** 返回状态码 */ 24 | + (MitRegexStateType)mit_makeMitRegexStatusMaker:(void (^)(MitRegexMaker * maker))block; 25 | 26 | /** 返回状态码所对应状态信息 */ 27 | + (NSString *)mit_makeMitRegexStatusStringMaker:(void (^)(MitRegexMaker * maker))block; 28 | @end 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 mcmengchen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex/MitRegexConst.m: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | /** 手机信息提示文本 */ 5 | NSString *const MitRegexPhoneRightTxt = @"手机号格式正确"; 6 | NSString *const MitRegexPhoneMoreErrorTxt = @"手机号输入多余11位"; 7 | NSString *const MitRegexPhoneLessErrorTxt = @"手机号输入少于11位"; 8 | NSString * const MitRegexPhoneChatErrorTxt = @"手机格式错误"; 9 | 10 | /** 密码信息提示文本 */ 11 | NSString *const MitRegexPsdRightTxt = @"密码输入格式正确"; 12 | NSString *const MitRegexPsdMoreErrorTxt = @"密码输入位数过多"; 13 | NSString *const MitRegexPsdLessErrorTxt = @"密码输入位数过少"; 14 | NSString * const MitRegexPsdChatErrorTxt = @"密码格式错误"; 15 | 16 | /** 验证码信息提示文本 */ 17 | NSString *const MitRegexCodeRightTxt = @"验证码正确"; 18 | NSString *const MitRegexCodeErrorTxt = @"请输入4位验证码"; 19 | NSString * const MitRegexCodeChatErrorTxt = @"验证码格式错误"; 20 | 21 | /** 身份证错误信息 */ 22 | NSString * const MitRegexPersonalIdRightTxt = @"身份证输入格式正确"; 23 | NSString * const MitRegexPersonalIdErrorTxt = @"身份证输入位数错误"; 24 | NSString * const MitRegexPersonalIdChatErrorTxt = @"身份证格式错误"; 25 | 26 | /** 邮箱错误信息提示 */ 27 | NSString * const MitRegexEmailRightTxt = @"邮箱输入格式正确"; 28 | NSString * const MitRegexEmailChatErrorTxt = @"邮箱输入格式错误"; 29 | 30 | 31 | /** 编码格式错误提示文本 */ 32 | NSString *const MitRegexChatErrorTxt = @"输入格式错误"; -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex/NSObject+mitRegexMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+mitRegexMaker.m 3 | // ReactiveCocoaDe 4 | // 5 | // Created by MENGCHEN on 15/11/15. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import "NSObject+mitRegexMaker.h" 10 | 11 | @implementation NSObject (mitRegexMaker) 12 | 13 | 14 | #pragma mark ------------------ 获取处理类 ------------------ 15 | + (MitRegexMaker*)mit_makeMitRegexMaker:(void (^)(MitRegexMaker *))block{ 16 | MitRegexMaker*maker = [[MitRegexMaker alloc]init]; 17 | block(maker); 18 | return maker; 19 | } 20 | 21 | #pragma mark ------------------ 获取状态+状态码信息 ------------------ 22 | +(void)mit_makeMitRegexMaker:(void (^)(MitRegexMaker *))block MitValue:(void (^)(MitRegexStateType,NSString *,BOOL isPassed))mitBlock{ 23 | MitRegexMaker*maker = [[MitRegexMaker alloc]init]; 24 | block(maker); 25 | mitBlock(maker.status,maker.statusString,maker.isPassed); 26 | } 27 | 28 | #pragma mark ------------------ 获取状态 ------------------ 29 | + (MitRegexStateType)mit_makeMitRegexStatusMaker:(void (^)(MitRegexMaker *))block{ 30 | MitRegexMaker*maker = [[MitRegexMaker alloc]init]; 31 | block(maker); 32 | return maker.status; 33 | } 34 | #pragma mark ------------------ 获取状态码信息 ------------------ 35 | + (NSString *)mit_makeMitRegexStatusStringMaker:(void (^)(MitRegexMaker *))block{ 36 | MitRegexMaker*maker = [[MitRegexMaker alloc]init]; 37 | block(maker); 38 | return maker.statusString; 39 | } 40 | @end 41 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex/MitRegexConst.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | /* 5 | MitRegexStateTypePhoneRight, //手机号正确 6 | MitRegexStateTypePhoneMoreError,//手机号太多 7 | MitRegexStateTypePhoneLessError,//手机号太少 8 | MitRegexPhoneChatErrorTxt, //手机格式错误 9 | MitRegexStateTypePsdRight, //密码正确 10 | MitRegexStateTypePsdLessError, //密码太少 11 | MitRegexStateTypePsdMoreError, //密码太多 12 | MitRegexStateTypeChatError, //编码格式错误 13 | */ 14 | 15 | /** 手机信息错误提示文本 */ 16 | UIKIT_EXTERN NSString * const MitRegexPhoneRightTxt; 17 | UIKIT_EXTERN NSString * const MitRegexPhoneMoreErrorTxt; 18 | UIKIT_EXTERN NSString * const MitRegexPhoneLessErrorTxt; 19 | UIKIT_EXTERN NSString * const MitRegexPhoneChatErrorTxt; 20 | 21 | /** 密码信息错误提示文本 */ 22 | UIKIT_EXTERN NSString * const MitRegexPsdRightTxt; 23 | UIKIT_EXTERN NSString * const MitRegexPsdMoreErrorTxt; 24 | UIKIT_EXTERN NSString * const MitRegexPsdLessErrorTxt; 25 | UIKIT_EXTERN NSString * const MitRegexPsdChatErrorTxt; 26 | 27 | /** 验证码错误提示文本 */ 28 | UIKIT_EXTERN NSString * const MitRegexCodeRightTxt; 29 | UIKIT_EXTERN NSString * const MitRegexCodeErrorTxt; 30 | UIKIT_EXTERN NSString * const MitRegexCodeChatErrorTxt; 31 | 32 | /** 身份证错误信息 */ 33 | UIKIT_EXTERN NSString * const MitRegexPersonalIdRightTxt; 34 | UIKIT_EXTERN NSString * const MitRegexPersonalIdErrorTxt; 35 | UIKIT_EXTERN NSString * const MitRegexPersonalIdChatErrorTxt; 36 | 37 | 38 | /** 邮箱错误信息提示 */ 39 | UIKIT_EXTERN NSString * const MitRegexEmailRightTxt; 40 | UIKIT_EXTERN NSString * const MitRegexEmailChatErrorTxt; 41 | 42 | 43 | 44 | /** 编码格式错误提示文本 */ 45 | UIKIT_EXTERN NSString * const MitRegexChatErrorTxt; 46 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/project.xcworkspace/xcshareddata/MitCheckDemo.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "54BAFEC0C9B67E1ADCFF2FB2EB4E1D69F5527587", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "54BAFEC0C9B67E1ADCFF2FB2EB4E1D69F5527587" : 0, 8 | "AEC35ACC533216FDD54260E68A8A000410066971" : 0 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "2694D9A7-2691-49F5-8510-02C811A24A28", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "54BAFEC0C9B67E1ADCFF2FB2EB4E1D69F5527587" : "MitRegx\/", 13 | "AEC35ACC533216FDD54260E68A8A000410066971" : "" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "MitCheckDemo", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "MitCheckDemo\/MitCheckDemo.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/mcmengchen\/MitRegx.git", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "54BAFEC0C9B67E1ADCFF2FB2EB4E1D69F5527587" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/mcmengchen\/iOS---MIthcell-NSInvocation.git", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "AEC35ACC533216FDD54260E68A8A000410066971" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MitCheckDemo 4 | // 5 | // Created by MENGCHEN on 15/12/3. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | 10 | 11 | 12 | #import "ViewController.h" 13 | #import "MitRegex/MitRegex.h" 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | 24 | 25 | 26 | /** 第一种方式:获取状态 */ 27 | NSInteger type = [[NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 28 | maker.validateCodeNumber(@"1234"); 29 | }] status]; 30 | NSLog(@"typeOne = %ld",type); 31 | 32 | /** 第一种方式:获取状态详细信息 */ 33 | NSString * typeStr = [[NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 34 | maker.validateCodeNumber(@"1234"); 35 | }] statusString]; 36 | NSLog(@"typeDetail = %@",typeStr); 37 | 38 | /** 第二种方式:获取状态 */ 39 | NSInteger type1 = [NSObject mit_makeMitRegexStatusMaker:^(MitRegexMaker *maker) { 40 | maker.validateCodeNumber(@"1234"); 41 | }]; 42 | NSLog(@"type = %ld",type1); 43 | 44 | /** 第二种方式:获取详细信息 */ 45 | NSString * typeStr1 = [NSObject mit_makeMitRegexStatusStringMaker:^(MitRegexMaker *maker) { 46 | maker.validatePsd(@"1234"); 47 | }]; 48 | 49 | NSLog(@"typeStr = %@",typeStr1); 50 | 51 | /** 大招: 一段代码,完成所有校验: 52 | 如果之前前面一个条件的校验未通过,将不会再进行下一个校验,返回的状态值也是未通过的校验值 53 | 只有当校验条件全部通过的时候, isPassed 才为1. 54 | */ 55 | [NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 56 | maker.validateCodeNumber(@"1234").validatePhone(@"15941281116").validatePsd(@"123456").validatePersonalId(@"2103021991071").validateEmail(@"10086@qq.com"); 57 | } MitValue:^(MitRegexStateType statusType, NSString * statusStr , BOOL isPassed) { 58 | NSLog(@"是否通过校验 = %d 状态码 = %ld, 状态详细 = %@",isPassed,statusType,statusStr); 59 | }]; 60 | } 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex/MitRegexMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MitRegex.h 3 | // ReactiveCocoaDe 4 | // 5 | // Created by MENGCHEN on 15/11/15. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MitRegexConst.h" 11 | 12 | /** 13 | MitRegexStateType state type 14 | */ 15 | typedef NS_ENUM(NSUInteger, MitRegexStateType) { 16 | MitRegexStateTypePhoneRight, //手机号正确 17 | MitRegexStateTypePhoneMoreError, //手机号太多 18 | MitRegexStateTypePhoneLessError, //手机号太少 19 | MitRegexStateTypePhoneChatError, //手机编码格式错误 20 | MitRegexStateTypePsdRight, //密码正确 21 | MitRegexStateTypePsdLessError, //密码太少 22 | MitRegexStateTypePsdMoreError, //密码太多 23 | MitRegexStateTypePsdChatError, //密码格式错误 24 | MitRegexStateTypeCodeRight, //验证码正确 25 | MitRegexStateTypeCodeError, //验证码错误 26 | MitRegexStateTypeCodeChatError, //验证码格式错误 27 | MitRegexStateTypeChatError, //编码格式错误 28 | MitRegexStateTypePersonalIdRight, //身份证正确 29 | MitRegexStateTypePersonalIdNumberError, //身份证输入数量错误 30 | MitRegexStateTypePersonalIdCodeError, //身份证格式错误 31 | MitRegexStateTypeEmailError, //邮箱格式错误 32 | MitRegexStateTypeEmailRight, //邮箱格式正确 33 | }; 34 | 35 | 36 | 37 | @interface MitRegexMaker : NSObject 38 | 39 | /** 校验状态 */ 40 | @property(nonatomic, assign)MitRegexStateType status; 41 | 42 | /** 返回状态文本 */ 43 | @property(nonatomic, strong)NSString * statusString; 44 | 45 | /** 是否通过了校验 46 | 当连续校验多个值的时候会使用到此值. 47 | */ 48 | @property(nonatomic, getter=isPassed)BOOL passed; 49 | 50 | /** 校验手机号 */ 51 | - (MitRegexMaker * (^)(NSString * str))validatePhone; 52 | 53 | /** 校验密码 */ 54 | - (MitRegexMaker * (^)(NSString * str))validatePsd; 55 | 56 | /** 校验验证码 */ 57 | - (MitRegexMaker * (^)(NSString * str))validateCodeNumber; 58 | 59 | /** 验证身份证 */ 60 | - (MitRegexMaker * (^)(NSString * str))validatePersonalId; 61 | 62 | /** 验证 email */ 63 | - (MitRegexMaker*(^)(NSString *))validateEmail; 64 | @end 65 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MitCheckDemo 4 | // 5 | // Created by MENGCHEN on 15/12/3. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/xcuserdata/mengchen.xcuserdatad/xcschemes/MitCheckDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/xcuserdata/william.xcuserdatad/xcschemes/MitCheckDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [中文](https://github.com/mcmengchen/MitRegx#mitregx-1) 2 | # MitRegx 3 | + You can use MitRegx to verify many kinds of codes format. For example, phone code,secret code,verification code and Email code... 4 | 5 | --- 6 | # Install 7 | + You can use cocoaPods: 8 | ``` 9 | pod 'MitRegx' 10 | ``` 11 | + You can also download the zip and add the file called MitRegx to your project. 12 | 13 | --- 14 | # How to use MitRegx 15 | You can use MitRegx in the ways as follow: 16 | ### First Type: 17 | + Get state 18 | ``` 19 | NSInteger type = [[NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 20 | maker.validateCodeNumber(@"1234"); 21 | }] status]; 22 | NSLog(@"%ld",type); 23 | ``` 24 | + Get state's detail message 25 | ``` 26 | NSString * typeStr = [[NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 27 | maker.validateCodeNumber(@"1234"); 28 | }] statusString]; 29 | NSLog(@"%@",typeStr); 30 | ``` 31 | ### Second Type 32 | + Get state 33 | ``` 34 | /** */ 35 | NSInteger type1 = [NSObject mit_makeMitRegexStatusMaker:^(MitRegexMaker *maker) { 36 | maker.validateCodeNumber(@"1234"); 37 | }]; 38 | NSLog(@"%ld",type1); 39 | ``` 40 | + Get state's detail message 41 | ``` 42 | NSString * typeStr1 = [NSObject mit_makeMitRegexStatusStringMaker:^(MitRegexMaker *maker) { 43 | maker.validatePsd(@"1234"); 44 | }]; 45 | NSLog(@"%@",typeStr1); 46 | ``` 47 | ### You can verify many kinds of code in a word: 48 | ``` 49 | /** 50 | If a condition in front of the check failed, it will not continue the next check, and the state will be the last check result. 51 | Only if all of the condition check is passed, the value isPassed will set to one. 52 | */ 53 | [NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 54 | maker.validateCodeNumber(@"1234").validatePhone(@"15941281116").validatePsd(@"123456").validatePersonalId(@"2103021991071").validateEmail(@"41692292@roo.bo"); 55 | } MitValue:^(MitRegexStateType statusType, NSString * statusStr , BOOL isPassed) { 56 | NSLog(@"if passed the check = %d StateCode = %ld, State detail Message = %@",isPassed,statusType,statusStr); 57 | }]; 58 | ``` 59 | 60 | 61 | --- 62 | 63 | 64 | # MitRegx 65 | 你可以使用 MitRegx 来校验手机号格式,密码格式,验证码格式和 Email 格式。 66 | 67 | --- 68 | # 下载 69 | + 你可以使用 CocoaPods 来安装: 70 | ``` 71 | pod 'MitRegx' 72 | ``` 73 | + 你也可以下载压缩包,然后将 MitRegx 文件夹添加到你的工程中使用 74 | 75 | --- 76 | # 怎么样使用 MitRegx 77 | ### 第一种方式: 78 | + 获取状态 79 | ``` 80 | NSInteger type = [[NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 81 | maker.validateCodeNumber(@"1234"); 82 | }] status]; 83 | NSLog(@"%ld",type); 84 | ``` 85 | + 获取状态详细信息 86 | ``` 87 | NSString * typeStr = [[NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 88 | maker.validateCodeNumber(@"1234"); 89 | }] statusString]; 90 | NSLog(@"%@",typeStr); 91 | ``` 92 | ### 第二种方式: 93 | + 获取状态 94 | ``` 95 | /** */ 96 | NSInteger type1 = [NSObject mit_makeMitRegexStatusMaker:^(MitRegexMaker *maker) { 97 | maker.validateCodeNumber(@"1234"); 98 | }]; 99 | NSLog(@"%ld",type1); 100 | ``` 101 | + 获取详细信息 102 | ``` 103 | NSString * typeStr1 = [NSObject mit_makeMitRegexStatusStringMaker:^(MitRegexMaker *maker) { 104 | maker.validatePsd(@"1234"); 105 | }]; 106 | NSLog(@"%@",typeStr1); 107 | ``` 108 | ### 一段代码,完成所有校验: 109 | ``` 110 | /** 111 | 如果之前前面一个条件的校验未通过,将不会再进行下一个校验,返回的状态值也是未通过的校验值 112 | 只有当校验条件全部通过的时候, isPassed 才为1. 113 | */ 114 | [NSObject mit_makeMitRegexMaker:^(MitRegexMaker *maker) { 115 | maker.validateCodeNumber(@"1234").validatePhone(@"15941281116").validatePsd(@"123456").validatePersonalId(@"2103021991071").validateEmail(@"41692292@roo.bo"); 116 | } MitValue:^(MitRegexStateType statusType, NSString * statusStr , BOOL isPassed) { 117 | NSLog(@"是否通过校验 = %d 状态码 = %ld, 状态详细 = %@",isPassed,statusType,statusStr); 118 | }]; 119 | ``` 120 | 121 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | FCA080291C1066DC00E829B3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA080281C1066DC00E829B3 /* main.m */; }; 11 | FCA0802C1C1066DC00E829B3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA0802B1C1066DC00E829B3 /* AppDelegate.m */; }; 12 | FCA0802F1C1066DC00E829B3 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA0802E1C1066DC00E829B3 /* ViewController.m */; }; 13 | FCA080321C1066DC00E829B3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FCA080301C1066DC00E829B3 /* Main.storyboard */; }; 14 | FCA080341C1066DC00E829B3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FCA080331C1066DC00E829B3 /* Assets.xcassets */; }; 15 | FCA080371C1066DC00E829B3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FCA080351C1066DC00E829B3 /* LaunchScreen.storyboard */; }; 16 | FCA080451C10670500E829B3 /* MitRegexConst.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA080401C10670500E829B3 /* MitRegexConst.m */; }; 17 | FCA080461C10670500E829B3 /* MitRegexMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA080421C10670500E829B3 /* MitRegexMaker.m */; }; 18 | FCA080471C10670500E829B3 /* NSObject+mitRegexMaker.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA080441C10670500E829B3 /* NSObject+mitRegexMaker.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | FCA080241C1066DC00E829B3 /* MitCheckDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MitCheckDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | FCA080281C1066DC00E829B3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 24 | FCA0802A1C1066DC00E829B3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 25 | FCA0802B1C1066DC00E829B3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 26 | FCA0802D1C1066DC00E829B3 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | FCA0802E1C1066DC00E829B3 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | FCA080311C1066DC00E829B3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | FCA080331C1066DC00E829B3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | FCA080361C1066DC00E829B3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | FCA080381C1066DC00E829B3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | FCA0803F1C10670500E829B3 /* MitRegexConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MitRegexConst.h; sourceTree = ""; }; 33 | FCA080401C10670500E829B3 /* MitRegexConst.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MitRegexConst.m; sourceTree = ""; }; 34 | FCA080411C10670500E829B3 /* MitRegexMaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MitRegexMaker.h; sourceTree = ""; }; 35 | FCA080421C10670500E829B3 /* MitRegexMaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MitRegexMaker.m; sourceTree = ""; }; 36 | FCA080431C10670500E829B3 /* NSObject+mitRegexMaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+mitRegexMaker.h"; sourceTree = ""; }; 37 | FCA080441C10670500E829B3 /* NSObject+mitRegexMaker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+mitRegexMaker.m"; sourceTree = ""; }; 38 | FCA080481C10678300E829B3 /* MitRegex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MitRegex.h; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | FCA080211C1066DC00E829B3 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | FCA0801B1C1066DC00E829B3 = { 53 | isa = PBXGroup; 54 | children = ( 55 | FCA080261C1066DC00E829B3 /* MitCheckDemo */, 56 | FCA080251C1066DC00E829B3 /* Products */, 57 | ); 58 | sourceTree = ""; 59 | }; 60 | FCA080251C1066DC00E829B3 /* Products */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | FCA080241C1066DC00E829B3 /* MitCheckDemo.app */, 64 | ); 65 | name = Products; 66 | sourceTree = ""; 67 | }; 68 | FCA080261C1066DC00E829B3 /* MitCheckDemo */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | FCA0802A1C1066DC00E829B3 /* AppDelegate.h */, 72 | FCA0802B1C1066DC00E829B3 /* AppDelegate.m */, 73 | FCA0802D1C1066DC00E829B3 /* ViewController.h */, 74 | FCA0802E1C1066DC00E829B3 /* ViewController.m */, 75 | FCA0803E1C10670500E829B3 /* MitRegex */, 76 | FCA080301C1066DC00E829B3 /* Main.storyboard */, 77 | FCA080331C1066DC00E829B3 /* Assets.xcassets */, 78 | FCA080351C1066DC00E829B3 /* LaunchScreen.storyboard */, 79 | FCA080381C1066DC00E829B3 /* Info.plist */, 80 | FCA080271C1066DC00E829B3 /* Supporting Files */, 81 | ); 82 | path = MitCheckDemo; 83 | sourceTree = ""; 84 | }; 85 | FCA080271C1066DC00E829B3 /* Supporting Files */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | FCA080281C1066DC00E829B3 /* main.m */, 89 | ); 90 | name = "Supporting Files"; 91 | sourceTree = ""; 92 | }; 93 | FCA0803E1C10670500E829B3 /* MitRegex */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | FCA080481C10678300E829B3 /* MitRegex.h */, 97 | FCA0803F1C10670500E829B3 /* MitRegexConst.h */, 98 | FCA080401C10670500E829B3 /* MitRegexConst.m */, 99 | FCA080411C10670500E829B3 /* MitRegexMaker.h */, 100 | FCA080421C10670500E829B3 /* MitRegexMaker.m */, 101 | FCA080431C10670500E829B3 /* NSObject+mitRegexMaker.h */, 102 | FCA080441C10670500E829B3 /* NSObject+mitRegexMaker.m */, 103 | ); 104 | path = MitRegex; 105 | sourceTree = ""; 106 | }; 107 | /* End PBXGroup section */ 108 | 109 | /* Begin PBXNativeTarget section */ 110 | FCA080231C1066DC00E829B3 /* MitCheckDemo */ = { 111 | isa = PBXNativeTarget; 112 | buildConfigurationList = FCA0803B1C1066DC00E829B3 /* Build configuration list for PBXNativeTarget "MitCheckDemo" */; 113 | buildPhases = ( 114 | FCA080201C1066DC00E829B3 /* Sources */, 115 | FCA080211C1066DC00E829B3 /* Frameworks */, 116 | FCA080221C1066DC00E829B3 /* Resources */, 117 | ); 118 | buildRules = ( 119 | ); 120 | dependencies = ( 121 | ); 122 | name = MitCheckDemo; 123 | productName = MitCheckDemo; 124 | productReference = FCA080241C1066DC00E829B3 /* MitCheckDemo.app */; 125 | productType = "com.apple.product-type.application"; 126 | }; 127 | /* End PBXNativeTarget section */ 128 | 129 | /* Begin PBXProject section */ 130 | FCA0801C1C1066DC00E829B3 /* Project object */ = { 131 | isa = PBXProject; 132 | attributes = { 133 | LastUpgradeCheck = 0710; 134 | ORGANIZATIONNAME = MENGCHEN; 135 | TargetAttributes = { 136 | FCA080231C1066DC00E829B3 = { 137 | CreatedOnToolsVersion = 7.1; 138 | }; 139 | }; 140 | }; 141 | buildConfigurationList = FCA0801F1C1066DC00E829B3 /* Build configuration list for PBXProject "MitCheckDemo" */; 142 | compatibilityVersion = "Xcode 3.2"; 143 | developmentRegion = English; 144 | hasScannedForEncodings = 0; 145 | knownRegions = ( 146 | en, 147 | Base, 148 | ); 149 | mainGroup = FCA0801B1C1066DC00E829B3; 150 | productRefGroup = FCA080251C1066DC00E829B3 /* Products */; 151 | projectDirPath = ""; 152 | projectRoot = ""; 153 | targets = ( 154 | FCA080231C1066DC00E829B3 /* MitCheckDemo */, 155 | ); 156 | }; 157 | /* End PBXProject section */ 158 | 159 | /* Begin PBXResourcesBuildPhase section */ 160 | FCA080221C1066DC00E829B3 /* Resources */ = { 161 | isa = PBXResourcesBuildPhase; 162 | buildActionMask = 2147483647; 163 | files = ( 164 | FCA080371C1066DC00E829B3 /* LaunchScreen.storyboard in Resources */, 165 | FCA080341C1066DC00E829B3 /* Assets.xcassets in Resources */, 166 | FCA080321C1066DC00E829B3 /* Main.storyboard in Resources */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | /* End PBXResourcesBuildPhase section */ 171 | 172 | /* Begin PBXSourcesBuildPhase section */ 173 | FCA080201C1066DC00E829B3 /* Sources */ = { 174 | isa = PBXSourcesBuildPhase; 175 | buildActionMask = 2147483647; 176 | files = ( 177 | FCA0802F1C1066DC00E829B3 /* ViewController.m in Sources */, 178 | FCA0802C1C1066DC00E829B3 /* AppDelegate.m in Sources */, 179 | FCA080451C10670500E829B3 /* MitRegexConst.m in Sources */, 180 | FCA080291C1066DC00E829B3 /* main.m in Sources */, 181 | FCA080461C10670500E829B3 /* MitRegexMaker.m in Sources */, 182 | FCA080471C10670500E829B3 /* NSObject+mitRegexMaker.m in Sources */, 183 | ); 184 | runOnlyForDeploymentPostprocessing = 0; 185 | }; 186 | /* End PBXSourcesBuildPhase section */ 187 | 188 | /* Begin PBXVariantGroup section */ 189 | FCA080301C1066DC00E829B3 /* Main.storyboard */ = { 190 | isa = PBXVariantGroup; 191 | children = ( 192 | FCA080311C1066DC00E829B3 /* Base */, 193 | ); 194 | name = Main.storyboard; 195 | sourceTree = ""; 196 | }; 197 | FCA080351C1066DC00E829B3 /* LaunchScreen.storyboard */ = { 198 | isa = PBXVariantGroup; 199 | children = ( 200 | FCA080361C1066DC00E829B3 /* Base */, 201 | ); 202 | name = LaunchScreen.storyboard; 203 | sourceTree = ""; 204 | }; 205 | /* End PBXVariantGroup section */ 206 | 207 | /* Begin XCBuildConfiguration section */ 208 | FCA080391C1066DC00E829B3 /* Debug */ = { 209 | isa = XCBuildConfiguration; 210 | buildSettings = { 211 | ALWAYS_SEARCH_USER_PATHS = NO; 212 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 213 | CLANG_CXX_LIBRARY = "libc++"; 214 | CLANG_ENABLE_MODULES = YES; 215 | CLANG_ENABLE_OBJC_ARC = YES; 216 | CLANG_WARN_BOOL_CONVERSION = YES; 217 | CLANG_WARN_CONSTANT_CONVERSION = YES; 218 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 219 | CLANG_WARN_EMPTY_BODY = YES; 220 | CLANG_WARN_ENUM_CONVERSION = YES; 221 | CLANG_WARN_INT_CONVERSION = YES; 222 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 223 | CLANG_WARN_UNREACHABLE_CODE = YES; 224 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 225 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 226 | COPY_PHASE_STRIP = NO; 227 | DEBUG_INFORMATION_FORMAT = dwarf; 228 | ENABLE_STRICT_OBJC_MSGSEND = YES; 229 | ENABLE_TESTABILITY = YES; 230 | GCC_C_LANGUAGE_STANDARD = gnu99; 231 | GCC_DYNAMIC_NO_PIC = NO; 232 | GCC_NO_COMMON_BLOCKS = YES; 233 | GCC_OPTIMIZATION_LEVEL = 0; 234 | GCC_PREPROCESSOR_DEFINITIONS = ( 235 | "DEBUG=1", 236 | "$(inherited)", 237 | ); 238 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 239 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 240 | GCC_WARN_UNDECLARED_SELECTOR = YES; 241 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 242 | GCC_WARN_UNUSED_FUNCTION = YES; 243 | GCC_WARN_UNUSED_VARIABLE = YES; 244 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 245 | MTL_ENABLE_DEBUG_INFO = YES; 246 | ONLY_ACTIVE_ARCH = YES; 247 | SDKROOT = iphoneos; 248 | }; 249 | name = Debug; 250 | }; 251 | FCA0803A1C1066DC00E829B3 /* Release */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | ALWAYS_SEARCH_USER_PATHS = NO; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BOOL_CONVERSION = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_EMPTY_BODY = YES; 263 | CLANG_WARN_ENUM_CONVERSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_UNREACHABLE_CODE = YES; 267 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 268 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 269 | COPY_PHASE_STRIP = NO; 270 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 271 | ENABLE_NS_ASSERTIONS = NO; 272 | ENABLE_STRICT_OBJC_MSGSEND = YES; 273 | GCC_C_LANGUAGE_STANDARD = gnu99; 274 | GCC_NO_COMMON_BLOCKS = YES; 275 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 276 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 277 | GCC_WARN_UNDECLARED_SELECTOR = YES; 278 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 279 | GCC_WARN_UNUSED_FUNCTION = YES; 280 | GCC_WARN_UNUSED_VARIABLE = YES; 281 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 282 | MTL_ENABLE_DEBUG_INFO = NO; 283 | SDKROOT = iphoneos; 284 | VALIDATE_PRODUCT = YES; 285 | }; 286 | name = Release; 287 | }; 288 | FCA0803C1C1066DC00E829B3 /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 292 | INFOPLIST_FILE = MitCheckDemo/Info.plist; 293 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 294 | PRODUCT_BUNDLE_IDENTIFIER = Mcking.MitCheckDemo; 295 | PRODUCT_NAME = "$(TARGET_NAME)"; 296 | }; 297 | name = Debug; 298 | }; 299 | FCA0803D1C1066DC00E829B3 /* Release */ = { 300 | isa = XCBuildConfiguration; 301 | buildSettings = { 302 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 303 | INFOPLIST_FILE = MitCheckDemo/Info.plist; 304 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 305 | PRODUCT_BUNDLE_IDENTIFIER = Mcking.MitCheckDemo; 306 | PRODUCT_NAME = "$(TARGET_NAME)"; 307 | }; 308 | name = Release; 309 | }; 310 | /* End XCBuildConfiguration section */ 311 | 312 | /* Begin XCConfigurationList section */ 313 | FCA0801F1C1066DC00E829B3 /* Build configuration list for PBXProject "MitCheckDemo" */ = { 314 | isa = XCConfigurationList; 315 | buildConfigurations = ( 316 | FCA080391C1066DC00E829B3 /* Debug */, 317 | FCA0803A1C1066DC00E829B3 /* Release */, 318 | ); 319 | defaultConfigurationIsVisible = 0; 320 | defaultConfigurationName = Release; 321 | }; 322 | FCA0803B1C1066DC00E829B3 /* Build configuration list for PBXNativeTarget "MitCheckDemo" */ = { 323 | isa = XCConfigurationList; 324 | buildConfigurations = ( 325 | FCA0803C1C1066DC00E829B3 /* Debug */, 326 | FCA0803D1C1066DC00E829B3 /* Release */, 327 | ); 328 | defaultConfigurationIsVisible = 0; 329 | }; 330 | /* End XCConfigurationList section */ 331 | }; 332 | rootObject = FCA0801C1C1066DC00E829B3 /* Project object */; 333 | } 334 | -------------------------------------------------------------------------------- /MitCheckDemo/MitCheckDemo/MitRegex/MitRegexMaker.m: -------------------------------------------------------------------------------- 1 | // 2 | // MitRegex.m 3 | // ReactiveCocoaDe 4 | // 5 | // Created by MENGCHEN on 15/11/15. 6 | // Copyright © 2015年 MENGCHEN. All rights reserved. 7 | // 8 | 9 | #import "MitRegexMaker.h" 10 | 11 | @implementation MitRegexMaker 12 | 13 | #pragma mark ------------------- 初始化 ------------------------ 14 | - (instancetype)init{ 15 | if (self = [super init]) { 16 | _passed = YES; 17 | } 18 | return self; 19 | } 20 | 21 | 22 | 23 | #pragma mark ------------------- 外部调用格式校验 API ------------------------ 24 | #pragma mark 校验手机号 格式 25 | - (MitRegexMaker *(^)(NSString *))validatePhone{ 26 | return ^(NSString *str){ 27 | if (_passed) { 28 | _status = [self regexPhoneNumber:str]; 29 | if (_status == MitRegexStateTypePhoneRight ) { 30 | _passed =YES; 31 | }else{ 32 | _passed = NO; 33 | } 34 | } 35 | return self; 36 | }; 37 | } 38 | 39 | #pragma mark 校验密码 格式 40 | - (MitRegexMaker *(^)(NSString *))validatePsd{ 41 | return ^(NSString *str){ 42 | if (_passed) { 43 | _status = [self regexPsdNumber:str]; 44 | if (_status == MitRegexStateTypePsdRight ) { 45 | _passed =YES; 46 | }else{ 47 | _passed = NO; 48 | } 49 | } 50 | return self; 51 | }; 52 | } 53 | #pragma mark 校验验证码 格式 54 | - (MitRegexMaker *(^)(NSString *))validateCodeNumber{ 55 | return ^(NSString *str){ 56 | if (_passed) { 57 | _status = [self regexCodeNumber:str]; 58 | if (_status == MitRegexStateTypeCodeRight ) { 59 | _passed =YES; 60 | }else{ 61 | _passed = NO; 62 | } 63 | } 64 | return self; 65 | }; 66 | } 67 | 68 | #pragma mark 校验身份证 格式 69 | - (MitRegexMaker *(^)(NSString *))validatePersonalId{ 70 | return ^(NSString * str){ 71 | if (_passed) { 72 | _status = [self validateIdentityCard:str]; 73 | if (_status == MitRegexStateTypePersonalIdRight) { 74 | _passed = YES; 75 | }else{ 76 | _passed = NO; 77 | } 78 | return self; 79 | }; 80 | return self; 81 | }; 82 | } 83 | #pragma mark 校验邮箱 格式 84 | - (MitRegexMaker*(^)(NSString *))validateEmail{ 85 | return ^(NSString * str){ 86 | if (_passed) { 87 | _status = [self validateEmail:str]; 88 | if (_status == MitRegexStateTypeEmailRight) { 89 | _passed = YES; 90 | }else{ 91 | _passed = NO; 92 | } 93 | return self; 94 | }; 95 | return self; 96 | }; 97 | 98 | 99 | } 100 | 101 | 102 | 103 | #pragma mark ------------------- 正则校验 ------------------------ 104 | #pragma action: 邮箱 格式 105 | - (MitRegexStateType) validateEmail:(NSString *)email 106 | { 107 | NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; 108 | NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; 109 | if ([emailTest evaluateWithObject:email]) { 110 | [self changeStatusString:MitRegexStateTypeEmailRight]; 111 | return MitRegexStateTypeEmailRight; 112 | }else{ 113 | [self changeStatusString:MitRegexStateTypeEmailError]; 114 | return MitRegexStateTypeEmailError; 115 | } 116 | } 117 | 118 | #pragma action: 手机号 格式 119 | - (MitRegexStateType)regexPhoneNumber:(NSString*)phoneNum{ 120 | //由于小灵通的概率太小,也由于随时有可能出现新号,这里对手机号的校验只做是否是11位,具体格式是否符合最好扔给后台做校验。 121 | // NSString * regex = @"^[1][3758][0-9]{9}$"; 122 | NSString * regex = @"^[0-9]{11}$"; 123 | NSPredicate * pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; 124 | BOOL isMatch = [pred evaluateWithObject:phoneNum]; 125 | if(isMatch){ 126 | [self changeStatusString:MitRegexStateTypePhoneRight]; 127 | return MitRegexStateTypePhoneRight; 128 | } 129 | NSInteger length = phoneNum.length ; 130 | if(length < 11){ 131 | [self changeStatusString:MitRegexStateTypePhoneLessError]; 132 | return MitRegexStateTypePhoneLessError; 133 | }else if(length > 11){ 134 | [self changeStatusString:MitRegexStateTypePhoneMoreError]; 135 | return MitRegexStateTypePhoneMoreError; 136 | } 137 | [self changeStatusString:MitRegexStateTypePhoneChatError]; 138 | return MitRegexStateTypePhoneChatError; 139 | } 140 | 141 | 142 | #pragma action: 密码 格式 143 | - (MitRegexStateType)regexPsdNumber:(NSString*)psd{ 144 | NSUInteger length = psd.length; 145 | if(length < 6){ 146 | [self changeStatusString:MitRegexStateTypePsdLessError]; 147 | return MitRegexStateTypePsdLessError; 148 | } else if(length >= 25) { 149 | [self changeStatusString:MitRegexStateTypePsdMoreError]; 150 | return MitRegexStateTypePsdMoreError; 151 | } 152 | [self changeStatusString:MitRegexStateTypePsdRight]; 153 | 154 | return MitRegexStateTypePsdRight; 155 | } 156 | 157 | 158 | #pragma action: 验证码 格式 159 | - (MitRegexStateType)regexCodeNumber:(NSString*)str{ 160 | NSString * regex = @"^[0-9]{4}$"; 161 | NSPredicate * pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; 162 | BOOL isMatch = [pred evaluateWithObject:str]; 163 | isMatch? [self changeStatusString:MitRegexStateTypeCodeRight]:[self changeStatusString:MitRegexStateTypeCodeError]; 164 | return isMatch? MitRegexStateTypeCodeRight:MitRegexStateTypeCodeChatError; 165 | } 166 | 167 | 168 | #pragma action: 身份证 格式 169 | - (MitRegexStateType) validateIdentityCard: (NSString *)identityCard 170 | { 171 | BOOL flag; 172 | if (identityCard.length <= 0) { 173 | flag = NO; 174 | return flag; 175 | } 176 | NSString *regex2 = @"^(\\d{14}|\\d{17})(\\d|[xX])$"; 177 | NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2]; 178 | if ([identityCardPredicate evaluateWithObject:identityCard]) { 179 | [self changeStatusString:MitRegexStateTypePersonalIdRight]; 180 | return MitRegexStateTypePersonalIdRight; 181 | }else{ 182 | [self changeStatusString:MitRegexStateTypePersonalIdCodeError]; 183 | return MitRegexStateTypePersonalIdCodeError; 184 | } 185 | } 186 | 187 | #pragma mark ------------------ 验证身份证(舍弃) ------------------ 188 | - (MitRegexStateType)regexPersonalId:(NSString*)str{ 189 | str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 190 | NSInteger length =0; 191 | if (!str) { 192 | [self changeStatusString:MitRegexStateTypePersonalIdNumberError]; 193 | return MitRegexStateTypePersonalIdNumberError; 194 | }else { 195 | length = str.length; 196 | 197 | if (length !=15 && length !=18) { 198 | [self changeStatusString:MitRegexStateTypePersonalIdNumberError]; 199 | return MitRegexStateTypePersonalIdNumberError; 200 | } 201 | } 202 | // 省份代码 203 | NSArray *areasArray =@[@"11",@"12", @"13",@"14", @"15",@"21", @"22",@"23", @"31",@"32", @"33",@"34", @"35",@"36", @"37",@"41", @"42",@"43", @"44",@"45", @"46",@"50", @"51",@"52", @"53",@"54", @"61",@"62", @"63",@"64", @"65",@"71", @"81",@"82", @"91"]; 204 | NSString *valuestart2 = [str substringToIndex:2]; 205 | BOOL areaFlag = NO; 206 | for (NSString *areaCode in areasArray) { 207 | if ([areaCode isEqualToString:valuestart2]) { 208 | areaFlag =YES; 209 | break; 210 | } 211 | } 212 | 213 | if (!areaFlag) { 214 | [self changeStatusString:MitRegexStateTypePersonalIdCodeError]; 215 | return MitRegexStateTypePersonalIdCodeError; 216 | } 217 | 218 | 219 | NSRegularExpression *regularExpression; 220 | NSUInteger numberofMatch; 221 | 222 | int year =0; 223 | switch (length) { 224 | case 15: 225 | year = [str substringWithRange:NSMakeRange(6,2)].intValue +1900; 226 | 227 | if (year %4 ==0 || (year %100 ==0 && year %4 ==0)) { 228 | //测试出生日期的合法性 229 | regularExpression = [[NSRegularExpression alloc]initWithPattern:@"^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$" 230 | options:NSRegularExpressionCaseInsensitive 231 | error:nil]; 232 | }else { 233 | //测试出生日期的合法性 234 | regularExpression = [[NSRegularExpression alloc]initWithPattern:@"^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$" 235 | options:NSRegularExpressionCaseInsensitive 236 | error:nil]; 237 | } 238 | numberofMatch = [regularExpression numberOfMatchesInString:str 239 | options:NSMatchingReportProgress 240 | range:NSMakeRange(0, str.length)]; 241 | 242 | if(numberofMatch >0) { 243 | [self changeStatusString:MitRegexStateTypePersonalIdRight]; 244 | return MitRegexStateTypePersonalIdRight; 245 | }else { 246 | [self changeStatusString:MitRegexStateTypePersonalIdCodeError]; 247 | return MitRegexStateTypePersonalIdCodeError; 248 | } 249 | case 18: 250 | year = [str substringWithRange:NSMakeRange(6,4)].intValue; 251 | if (year %4 ==0 || (year %100 ==0 && year %4 ==0)) { 252 | 253 | regularExpression = [[NSRegularExpression alloc]initWithPattern:@"^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$" 254 | options:NSRegularExpressionCaseInsensitive 255 | error:nil];//测试出生日期的合法性 256 | }else { 257 | regularExpression = [[NSRegularExpression alloc]initWithPattern:@"^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$" 258 | options:NSRegularExpressionCaseInsensitive 259 | error:nil];//测试出生日期的合法性 260 | } 261 | numberofMatch = [regularExpression numberOfMatchesInString:str 262 | options:NSMatchingReportProgress 263 | range:NSMakeRange(0, str.length)]; 264 | if(numberofMatch >0) { 265 | int S = ([str substringWithRange:NSMakeRange(0,1)].intValue + [str substringWithRange:NSMakeRange(10,1)].intValue) *7 + ([ str substringWithRange:NSMakeRange(1,1)].intValue + [str substringWithRange:NSMakeRange(11,1)].intValue) *9 + ([str substringWithRange:NSMakeRange(2,1)].intValue + [str substringWithRange:NSMakeRange(12,1)].intValue) *10 + ([str substringWithRange:NSMakeRange(3,1)].intValue + [str substringWithRange:NSMakeRange(13,1)].intValue) *5 + ([str substringWithRange:NSMakeRange(4,1)].intValue + [str substringWithRange:NSMakeRange(14,1)].intValue) *8 + ([str substringWithRange:NSMakeRange(5,1)].intValue + [str substringWithRange:NSMakeRange(15,1)].intValue) *4 + ([str substringWithRange:NSMakeRange(6,1)].intValue + [str substringWithRange:NSMakeRange(16,1)].intValue) *2 + [str substringWithRange:NSMakeRange(7,1)].intValue *1 + [str substringWithRange:NSMakeRange(8,1)].intValue *6 + [str substringWithRange:NSMakeRange(9,1)].intValue *3; 266 | int Y = S %11; 267 | NSString *M =@"F"; 268 | NSString *JYM =@"10X98765432"; 269 | // 判断校验位 270 | M = [JYM substringWithRange:NSMakeRange(Y,1)]; 271 | if ([M isEqualToString:[str substringWithRange:NSMakeRange(17,1)]]) { 272 | [self changeStatusString:MitRegexStateTypePersonalIdRight]; 273 | return MitRegexStateTypePersonalIdRight;// 检测ID的校验位 274 | }else { 275 | [self changeStatusString:MitRegexStateTypePersonalIdCodeError]; 276 | return MitRegexStateTypePersonalIdCodeError; 277 | } 278 | 279 | }else { 280 | [self changeStatusString:MitRegexStateTypePersonalIdCodeError]; 281 | 282 | return MitRegexStateTypePersonalIdCodeError; 283 | } 284 | default: 285 | { 286 | [self changeStatusString:MitRegexStateTypePersonalIdCodeError]; 287 | return MitRegexStateTypePersonalIdCodeError; 288 | } 289 | } 290 | } 291 | 292 | #pragma mark ------------------- 修改输出状态码和详细信息 ------------------------ 293 | - (void)changeStatusString:(MitRegexStateType)status{ 294 | switch (status) { 295 | case MitRegexStateTypePhoneRight: 296 | self.statusString = MitRegexPhoneRightTxt; 297 | break; 298 | case MitRegexStateTypePhoneLessError: 299 | self.statusString = MitRegexPhoneLessErrorTxt; 300 | break; 301 | case MitRegexStateTypePhoneMoreError: 302 | self.statusString = MitRegexPhoneMoreErrorTxt; 303 | break; 304 | case MitRegexStateTypePsdRight: 305 | self.statusString = MitRegexPsdRightTxt; 306 | break; 307 | case MitRegexStateTypePsdLessError: 308 | self.statusString = MitRegexPsdLessErrorTxt; 309 | break; 310 | case MitRegexStateTypePsdMoreError: 311 | self.statusString = MitRegexPsdMoreErrorTxt; 312 | break; 313 | case MitRegexStateTypeCodeError: 314 | self.statusString = MitRegexCodeErrorTxt; 315 | break; 316 | case MitRegexStateTypeCodeRight: 317 | self.statusString = MitRegexCodeRightTxt; 318 | break; 319 | case MitRegexStateTypeChatError: 320 | self.statusString = MitRegexChatErrorTxt; 321 | break; 322 | case MitRegexStateTypePhoneChatError: 323 | self.statusString = MitRegexPhoneChatErrorTxt; 324 | break; 325 | case MitRegexStateTypeCodeChatError: 326 | self.statusString = MitRegexCodeChatErrorTxt; 327 | break; 328 | case MitRegexStateTypePsdChatError: 329 | self.statusString = MitRegexPsdChatErrorTxt; 330 | break; 331 | case MitRegexStateTypePersonalIdRight: 332 | self.statusString = MitRegexPersonalIdRightTxt; 333 | break; 334 | case MitRegexStateTypePersonalIdCodeError: 335 | self.statusString = MitRegexPersonalIdChatErrorTxt; 336 | break; 337 | case MitRegexStateTypePersonalIdNumberError: 338 | self.statusString = MitRegexPersonalIdErrorTxt; 339 | break; 340 | case MitRegexStateTypeEmailError: 341 | self.statusString = MitRegexEmailChatErrorTxt; 342 | break; 343 | case MitRegexStateTypeEmailRight: 344 | self.statusString = MitRegexEmailRightTxt; 345 | break; 346 | } 347 | } 348 | 349 | 350 | @end 351 | --------------------------------------------------------------------------------