In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail about the IOS regular expression to determine the input type, the editor thinks it is very practical, so share it with you as a reference, I hope you can get something after reading this article.
In the process of development, it is sometimes necessary to judge the type entered by the user. The most common is the user name and password on the registration page. The code is sorted out as follows:
Only for Chinese
-(BOOL) onlyInputChineseCharacters: (NSString*) string {NSString* zhString = @ "[\ u4e00 -\ u9fa5] +"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", zhString]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Can only be numbers
-(BOOL) onlyInputTheNumber: (NSString*) string {NSString* numString = @ "[0-9] *"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", numString]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Can only be lowercase
-(BOOL) onlyInputLowercaseLetter: (NSString*) string {NSString* regex = @ "[a Murz] *"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
* uppercase only
-(BOOL) onlyInputACapital: (NSString*) string {NSString* regex = @ "[Amurz] *"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Allow case
-(BOOL) InputCapitalAndLowercaseLetter: (NSString*) string {NSString* regex = @ "[a-zA-Z] *"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Uppercase or numeric allowed (unlimited number of words)
-(BOOL) inputLettersOrNumbers: (NSString*) string {NSString* regex = @ "[a-zA-Z0-9] *"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Uppercase and lowercase or numbers are allowed (word limit)
-(BOOL) inputNumberOrLetters: (NSString*) name {NSString* userNameRegex = @ "^ [A-Za-z0-9] {6 NSPredicate predicateWithFormat:@ 20} + $"; NSPredicate * userNamePredicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", userNameRegex]; BOOL inputString = [userNamePredicate evaluateWithObject:name]; return inputString;}
Allow Chinese characters or numbers (unlimited number of characters)
-(BOOL) inputChineseOrNumbers: (NSString*) string {NSString* regex = @ "[\ u4e00 -\ u9fa5] + [0-9] *"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Allow Chinese characters or numbers (limit the number of characters)
-(BOOL) inputChineseOrNumbersLimit: (NSString*) string {NSString* regex = @ "[\ u4e00 -\ u9fa5] [0-9] {6 SELF MATCHES 20} + $"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Allow Chinese characters, upper and lower case or numbers (unlimited number of words)
-(BOOL) inputChineseOrLettersAndNumbersNum: (NSString*) string {NSString* regex = @ "[\ u4e00 -\ u9fa5] + [A-Za-z0-9] *"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString;}
Allow Chinese characters, uppercase and lowercase or numbers (limited to the number of characters)
-(BOOL) inputChineseOrLettersNumberslimit: (NSString*) string {NSString* regex = @ "[\ u4e00 -\ u9fa5] + [A-Za-z0-9] {6 predicate 20} + $"; NSPredicate * predicate = [NSPredicate predicateWithFormat:@ "SELF MATCHES% @", regex]; BOOL inputString = [predicate evaluateWithObject:string]; return inputString } this is the end of the article on "judging input types by IOS regular expressions". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.