fork(3) download
  1. #import <objc/objc.h>
  2. #import <objc/Object.h>
  3. #import <Foundation/Foundation.h>
  4.  
  5. @implementation TestObj
  6. int main()
  7. {
  8. NSString *pattern = @"^/api/v1/news/([0-9]+)/\\?categoryId=([0-9]+)$";
  9. NSString *string = @"/api/v1/news/123/?categoryId=22";
  10. NSError *error = nil;
  11. NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
  12. NSTextCheckingResult *match = [regex firstMatchInString:string
  13. options:0
  14. range:NSMakeRange(0, string.length)];
  15. NSLog(@"Group 1 number: %@", [string substringWithRange:[match rangeAtIndex:1]]);
  16. NSLog(@"Group 2 number: %@", [string substringWithRange:[match rangeAtIndex:2]]);
  17. return 0;
  18. }
  19. @end
Success #stdin #stdout #stderr 0.03s 42856KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
2015-09-29 21:19:22.824 prog[6785] autorelease called without pool for object (0x82044c0) of class NSRegularExpression in thread <NSThread: 0x81c6800>
2015-09-29 21:19:22.825 prog[6785] autorelease called without pool for object (0x8262d48) of class GSRegularExpressionCheckingResult in thread <NSThread: 0x81c6800>
2015-09-29 21:19:22.825 prog[6785] autorelease called without pool for object (0x8204cd8) of class GSCInlineString in thread <NSThread: 0x81c6800>
2015-09-29 21:19:22.825 prog[6785] Group 1 number: 123
2015-09-29 21:19:22.825 prog[6785] autorelease called without pool for object (0x8262e18) of class GSCInlineString in thread <NSThread: 0x81c6800>
2015-09-29 21:19:22.825 prog[6785] Group 2 number: 22