#import <objc/objc.h>
#import <objc/Object.h>
#import <Foundation/Foundation.h>


int main()
{
    NSString *pattern = @"(.*)[<]Foobar[>]";
    NSString *s = @"abcde\n		fghij<FooBar>";
    NSError* regexError = nil;
    NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:pattern
       options:NSRegularExpressionDotMatchesLineSeparators
       error:&regexError];
 
    if (regexError)
    {
       NSLog(@"Regex creation failed with error: %@", [regexError description]);
       return 0;
    }
    NSArray* matches = [regex matchesInString:s 
                           options:NSMatchingWithoutAnchoringBounds 
                          range:NSMakeRange(0, s.length)
                          ];
   for (NSTextCheckingResult *match in matches) {
       NSRange matchRange = [match range];
       NSString *m = [s substringWithRange:matchRange];
       NSLog(@"Matched string: %@", m);
    }
}
