Reputation: 61
I want to delete a part of my NSString.
I have this one : @"Test Hello http://www.google.fr wolrd"
And I want to have in output : @"Test Hello other world"
Some ideas? Thx :)
Upvotes: 1
Views: 377
Reputation: 2682
You can use NSDataDetector
to search the string for any links (per Apple's formulas of course).
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil];
Then you can use stringByReplacingMatchesInString:options:range:withTemplate:
to replace all the links with an empty string.
Upvotes: 2
Reputation: 962
You could use RegexKitLite like regex library to filter any URL from the string using methods like stringByReplacingOccurrencesOfRegex
.
Upvotes: 0