tags:

views:

34

answers:

2

\/images\/content\/booking_thumbs_uk\/s_kl\/50000\/THB_999_H54007.jpg

changes to:

/images/content/booking_thumbs_uk/s_kl/00000/THB_999_H2470.jpg

A: 

You can use newString = [oldString stringByReplacingOccurrencesOfString:@"\\" withString:@""];

livingtech
also, look at the other functions in the "Replacing Substrings" section in the NSString documentation.
livingtech
That doesn't work - 'Missing terminating character'
TheLearner
You need to double the backslash to represent one backslash. `@"\\"`.
Yuji
ahh, oops! editing my answer. hehe.
livingtech
A: 
    NSString* original=@"\\/images\\/content\\/booking_thumbs_uk\\/s_kl\\/50000\\/THB_999_H54007.jpg";
    NSString* removed=[original stringByReplacingOccurrencesOfString:@"\\" withString:@""];
    NSLog(@"%@",removed);  // shows /images/content/booking_thumbs_uk/s_kl/00000/THB_999_H2470.jpg

Be very careful, because inside the source code between "..." the backslash has a special meaning. In order to represent an honest backslash, you need to double it, like "\\".

Yuji
lol was wondering what was going on - must have updated your post? works now thanks
TheLearner
I don't know what happened; my post got corrupted when I first posted it. It looked OK on the preview page. So I re-posted the same thing, which works now. Strange.
Yuji
No worries all good now :))
TheLearner