美文网首页
登录字符串校验

登录字符串校验

作者: 三岁就很乖 | 来源:发表于2016-05-20 14:15 被阅读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];
            }
        }
    
    

    相关文章

      网友评论

          本文标题:登录字符串校验

          本文链接:https://www.haomeiwen.com/subject/eddnrttx.html