3
    NSString *body = @"...";

    // Remove all HTML and formatting from body
    NSError *error = nil;
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(<.*?>|\\n|\\t|&.*?;)" options:NSRegularExpressionCaseInsensitive error:&error];
    body = [regex stringByReplacingMatchesInString:body options:0 range:NSMakeRange(0, [body length]) withTemplate:@""];

But when I compile it, I get this error:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument'

I tested the pattern in a regular expression editor and it works, I don't see what I'm doing wrong here.

user212541
  • 1,878
  • 1
  • 21
  • 30

0 Answers0