By default, the dot .
does not match a line separator.
Since the text that you want to capture spans multiple lines, you have to add the
NSRegularExpressionDotMatchesLineSeparators
option:
NSRegularExpression *pattern = [NSRegularExpression regularExpressionWithPattern:regex
options:NSRegularExpressionDotMatchesLineSeparators
error:&error];
Alternatively, add (?s)
to the pattern to add the "s" flag.