I have a NSString with this content:
<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
<mediaid>y2q62</mediaid>
<mediaurl>http://twitpic.com/url</mediaurl>
</rsp>
Now I want to get the twitpic-Url in a new NSString without all the other Strings. How can I make this? Can I search in NSStrings? Like: Find the strings between the Strings ? Or can I find directly URLs in a NSString?
Thanks for your help!
Use a regex: RegexKitLite
Here’s a complete example using the HTTP matching URL from the RegexKitLite documentation. The RegexKitLite
-componentsMatchedByRegex:method will return aNSArrayof all the URL matches it finds in the string.Compile and run with: