fork download
  1. #import <objc/objc.h>
  2. #import <objc/Object.h>
  3. #import <Foundation/Foundation.h>
  4.  
  5.  
  6. int main()
  7. {
  8. NSString *pattern = @"(.*)[<]Foobar[>]";
  9. NSString *s = @"abcde\n fghij<FooBar>";
  10. NSError* regexError = nil;
  11. NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:pattern
  12. options:NSRegularExpressionDotMatchesLineSeparators
  13. error:&regexError];
  14.  
  15. if (regexError)
  16. {
  17. NSLog(@"Regex creation failed with error: %@", [regexError description]);
  18. return 0;
  19. }
  20. NSArray* matches = [regex matchesInString:s
  21. options:NSMatchingWithoutAnchoringBounds
  22. range:NSMakeRange(0, s.length)
  23. ];
  24. for (NSTextCheckingResult *match in matches) {
  25. NSRange matchRange = [match range];
  26. NSString *m = [s substringWithRange:matchRange];
  27. NSLog(@"Matched string: %@", m);
  28. }
  29. }
  30.  
Success #stdin #stdout #stderr 0.01s 128704KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
2017-08-31 11:03:25.188 prog[10251:10251] autorelease called without pool for object (0x691f10) of class NSRegularExpression in thread <NSThread: 0x69c880>{name = (null), num = 10251}
2017-08-31 11:03:25.188 prog[10251:10251] autorelease called without pool for object (0x7a2a70) of class GSMutableArray in thread <NSThread: 0x69c880>{name = (null), num = 10251}