0

I have this NSString:

<title>My Friends Website</title>

How do I pull out My Friends Website into it's own NSString on iOS with Objective-C?

Ethan Allen
  • 14,425
  • 24
  • 101
  • 194
  • See the following search results: http://stackoverflow.com/search?q=%5Bios%5D+extract+string+between – rmaddy Nov 25 '13 at 23:52
  • 1
    This should help: http://stackoverflow.com/questions/277055/remove-html-tags-from-an-nsstring-on-the-iphone – TotoroTotoro Nov 25 '13 at 23:57
  • I'd say this question is a duplicate of what @BlackRider just linked. – prototypical Nov 26 '13 at 00:04
  • @prototypical The problem with that "duplicate" is it is a more general question about stripping HTML from a string. This question can be solved without the need of regular expressions and all of the other extra overhead. This can be solved with to simple `rangeOfString` calls and a `substringWithRange:` call. – rmaddy Nov 26 '13 at 00:19

1 Answers1

2

try that:

NSString *myString = [[@"<title>My Friends Website</title>" stringByReplacingOccurrencesOfString:@"<title>" withString:@""] stringByReplacingOccurrencesOfString:@"</title>" withString:@""]];
Astri
  • 575
  • 4
  • 10