As I mentioned in my comment, this question is a bit underspecified, but if we take at face value, then you want to extract the href
attribute from any <a>
tag in the string, it the file name extension is .mp3. I hope I got this right.
To be honest, I would have expected that you only needed the URL, but for now we'll go with the href attribute.
Your pattern to get these strings is basically right, there is just no need to use a positive look behind (which means that the href="
part is not included in the match). So with this pattern you should get what you need:
NSString *pattern = @"href=\"[^\"]+\\.mp3\"";
Notice that the url is matched by including all characters that are not a quotation mark, because otherwise you risk to match with a random ".mp3" string in the html text.