fork download
  1. #import <objc/objc.h>
  2. #import <objc/Object.h>
  3. #import <Foundation/Foundation.h>
  4.  
  5. void NSPrint(NSString *format, ...) {
  6. va_list args;
  7. va_start(args, format);
  8. NSString *string = [[NSString alloc] initWithFormat:format arguments:args];
  9. va_end(args);
  10. fprintf(stdout, "%s\n", [string UTF8String]);
  11. [string release];
  12. }
  13.  
  14. int main()
  15. {
  16. NSError *error = nil;
  17. NSString *pattern = @"/:\\S*?(?=/:|\\s|$)";
  18. NSString *string = @"/:012/:^_^/:^$^ some string";
  19. NSRange range = NSMakeRange(0, string.length);
  20. NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
  21. NSArray *matches = [regex matchesInString:string options:0 range:range];
  22. for (NSTextCheckingResult *match in matches) {
  23. NSRange matchRange = [match range];
  24. NSString *m = [string substringWithRange:matchRange];
  25. NSPrint(@"Matched string: %@", m);
  26. }
  27. return 0;
  28.  
  29.  
  30. }
  31.  
Success #stdin #stdout #stderr 0.01s 128704KB
stdin
Standard input is empty
stdout
Matched string: /:012
Matched string: /:^_^
Matched string: /:^$^
stderr
2017-05-08 14:45:35.045 prog[6619:6619] autorelease called without pool for object (0x1601f10) of class NSRegularExpression in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.045 prog[6619:6619] autorelease called without pool for object (0x1712ab0) of class GSMutableArray in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x1710980) of class GSRegularExpressionCheckingResult in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16bec70) of class GSRegularExpressionCheckingResult in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16b51c0) of class GSRegularExpressionCheckingResult in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16aa880) of class GSCInlineString in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16c3480) of class GSAutoreleasedMemory in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16b40c0) of class GSCInlineString in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16bc370) of class GSAutoreleasedMemory in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16da2c0) of class GSCInlineString in thread <NSThread: 0x160c880>{name = (null), num = 6619}
2017-05-08 14:45:35.046 prog[6619:6619] autorelease called without pool for object (0x16b1a70) of class GSAutoreleasedMemory in thread <NSThread: 0x160c880>{name = (null), num = 6619}