iOS:how 将 NSString 中的“\”替换为“/”?
iOS:how to replace '\' with '/' in NSString?
我有一个字符串:http://192.168.1.127:8080/static\res\upload\headImage16-5-28/ffb8cbe68970440293635545a4d25d6f.png
这里有很多'\'
(反斜杠)。
我想将 '\'
替换为 '/'
,该怎么做?
你可以使用这个方法:
Objective-C
NSString *replaced = [url stringByReplacingOccurrencesOfString:@"\" withString:@"/"];
Swift
let replaced = url.stringByReplacingOccurrencesOfString("\", withString: "/")
我有一个字符串:http://192.168.1.127:8080/static\res\upload\headImage16-5-28/ffb8cbe68970440293635545a4d25d6f.png
这里有很多'\'
(反斜杠)。
我想将 '\'
替换为 '/'
,该怎么做?
你可以使用这个方法:
Objective-C
NSString *replaced = [url stringByReplacingOccurrencesOfString:@"\" withString:@"/"];
Swift
let replaced = url.stringByReplacingOccurrencesOfString("\", withString: "/")