Sivanathan
Sivanathan

Reputation: 1213

Eliminate the char's in url strings

i am new to iphone. i want to eliminate chars from %0A onwards in below url string and %20 also.please any one give some solns.

case:1

http://www.sampleurl.com-feb 1.2161280%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20

case:2

%0A%20%20%20%20%20%20http://www.sampleurl.com-feb.html%0A%20%20%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20

in case 2 also, want to eliminate chars before and after url.

Upvotes: 1

Views: 157

Answers (1)

Nikolai Ruhe
Nikolai Ruhe

Reputation: 81878

Your strings look like they are url encoded and contain whitespace at the beginning and end.

NSString* decodedString = [myString stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

NSString* cleanedString = [decodedString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

Now cleanedString is what you are looking for.

Upvotes: 4

Related Questions