iOS字符串替换

  NSString * str = @"123124124";
    NSString * s = @"12";
    str = [str stringByReplacingOccurrencesOfString:s withString:@"hhh"];
    NSLog(@"%@",str);


      
        var str = "121412412515"
        let s = "12"
        if str.contains(s) {
           str = str.replacingOccurrences(of: s, with: "hh")
        }
        print(str)

 

转载于:https://my.oschina.net/wayzhu/blog/3099119

你可能感兴趣的:(iOS字符串替换)