I have this regular expression in objective-c
NSString* searchString = [searchBlock stringByReplacingOccurrencesOfString:@"<(.*?)>" withString:@"" options: NSRegularExpressionSearch range:NSMakeRange (0, [searchBlock length])];
The code should remove everything that comes between pointy brackets <> and it seems to work most of the time but seems to fail on this case and I’m not sure why:
<a href="http://www.twitter.com/starkpo">
<img height="120" width="124" alt="Follow us @starkpo." style="border: 0;"
src="http://www.thestarkingtonpost.com/wp-content/uploads/2009/09/twitter-master.jpg"
title="Join us on Twitter" />
</a>
<p style="font-size: 11px; line-height: 17px; margin: 0; padding: 0 4px 5px;">Follow us @starkpo.</p></div>
returns:
<img height="120" width="124" alt="Follow us @starkpo." style="border: 0;"
src="http://www.thestarkingtonpost.com/wp-content/uploads/2009/09/twitter-master.jpg"
title="Join us on Twitter" />
Follow us @starkpo.
The expected answer is simply to return the plain text: Follow us @starkpo.
Any idea why it seems to be ignoring the self closing tag?
Thanks!
You need to tell the regex engine to make
.match newlines as well.Add
NSRegularExpressionDotMatchesLineSeparatorstooptions.