fork(1) 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.  
  13. NSRange textRange = NSMakeRange(0, string.length);
  14. NSRange matchRange = [regex rangeOfFirstMatchInString:string options:NSMatchingReportProgress range:textRange];
  15.  
  16. // Did we find a matching range
  17. if (matchRange.location != NSNotFound)
  18. NSLog (@"YES! It is matched!");
  19. else
  20. NSLog (@"NO MATCH!");
  21. return 0;
  22. }
  23. @end
Success #stdin #stdout #stderr 0.03s 42856KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
2015-09-29 20:57:34.492 prog[19628] autorelease called without pool for object (0x90574c0) of class NSRegularExpression in thread <NSThread: 0x9019800>
2015-09-29 20:57:34.494 prog[19628] YES! It is matched!