登录字符串校验
2016-05-20 本文已影响34人
三岁就很乖
//去除textfield.text字符串中前后字符串
NSString *pwdStr = [_pwdTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
//字符串替换
NSString *search = @"_";
NSString *replace= @"-";
NSRange substr = [trainNumber rangeOfString:search];
while (substr.location!=NSNotFound) {
[trainNumber replaceCharactersInRange:substr withString:replace];
substr = [trainNumber rangeOfString:search];
}
//字符串中小写字母,转换成大写字母
for (int i=0; i<trainNumber.length; i++) {
NSRange range = NSMakeRange(i, 1);
NSString *subString = [trainNumber substringWithRange:range];
const char *cString = [subString UTF8String];
if (strlen(cString)==1) {
NSString *changeUper = [subString uppercaseString];
[trainNumber replaceCharactersInRange:range withString:changeUper];
}
}