iOS OBject-C 对字符串取消转义
在iOS Objective-C中取消对字符串的转义可以使用NSString的stringByReplacingOccurrencesOfString:withString:方法。
NSString *escapedString = @"This is a \"quoted\" string.";
NSString *unescapedString = [escapedString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
在上面的例子中,我们使用stringByReplacingOccurrencesOfString:withString:方法将字符串中的反斜杠字符\替换为空字符串"",从而取消了转义。最终得到的unescapedString值为This is a "quoted" string.。
原文地址: https://www.cveoy.top/t/topic/hHW7 著作权归作者所有。请勿转载和采集!