当前位置:编程学习 > wap >>

iOS 过滤空格

  //过滤空格
    NSString * urlStr = @"   A as    dd  dmm ";
    NSLog(@"urlStr = %@",urlStr);
    
    //过滤字符串前后的空格
    urlStr = [urlStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    NSLog(@"urlStr = %@",urlStr);
    
    //过滤中间空格
    urlStr = [urlStr stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSLog(@"urlStr = %@",urlStr);
补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,