#import <objc/objc.h>
#import <objc/Object.h>
#import <Foundation/Foundation.h>
@implementation TestObj
int main( )
{
NSString * pattern = @"^/api/v1/news/([0-9]+)/\\ ?categoryId=([0-9]+)$" ;
NSString * string = @"/api/v1/news/123/?categoryId=22abc" ;
NSError * error = nil;
NSRegularExpression * regex = [ NSRegularExpression regularExpressionWithPattern: pattern options: 0 error:& error] ;
NSRange textRange = NSMakeRange( 0 , string.length ) ;
NSRange matchRange = [ regex rangeOfFirstMatchInString: string options: NSMatchingReportProgress range: textRange] ;
// Did we find a matching range
if ( matchRange.location != NSNotFound)
NSLog ( @"YES! It is matched!" ) ;
else
NSLog ( @"NO MATCH!" ) ;
return 0 ;
}
@end
I2ltcG9ydCA8b2JqYy9vYmpjLmg+CiNpbXBvcnQgPG9iamMvT2JqZWN0Lmg+CiNpbXBvcnQgPEZvdW5kYXRpb24vRm91bmRhdGlvbi5oPgoKQGltcGxlbWVudGF0aW9uIFRlc3RPYmoKaW50IG1haW4oKQp7CglOU1N0cmluZyAqcGF0dGVybiA9IEAiXi9hcGkvdjEvbmV3cy8oWzAtOV0rKS9cXD9jYXRlZ29yeUlkPShbMC05XSspJCI7CglOU1N0cmluZyAqc3RyaW5nID0gQCIvYXBpL3YxL25ld3MvMTIzLz9jYXRlZ29yeUlkPTIyYWJjIjsKCU5TRXJyb3IgKmVycm9yID0gbmlsOwoJTlNSZWd1bGFyRXhwcmVzc2lvbiAqcmVnZXggPSBbTlNSZWd1bGFyRXhwcmVzc2lvbiByZWd1bGFyRXhwcmVzc2lvbldpdGhQYXR0ZXJuOnBhdHRlcm4gb3B0aW9uczowIGVycm9yOiZlcnJvcl07CgoJTlNSYW5nZSB0ZXh0UmFuZ2UgPSBOU01ha2VSYW5nZSgwLCBzdHJpbmcubGVuZ3RoKTsKCU5TUmFuZ2UgbWF0Y2hSYW5nZSA9IFtyZWdleCByYW5nZU9mRmlyc3RNYXRjaEluU3RyaW5nOnN0cmluZyBvcHRpb25zOk5TTWF0Y2hpbmdSZXBvcnRQcm9ncmVzcyByYW5nZTp0ZXh0UmFuZ2VdOwoKCS8vIERpZCB3ZSBmaW5kIGEgbWF0Y2hpbmcgcmFuZ2UKCWlmIChtYXRjaFJhbmdlLmxvY2F0aW9uICE9IE5TTm90Rm91bmQpCgkgICAgTlNMb2cgKEAiWUVTISBJdCBpcyBtYXRjaGVkISIpOwoJZWxzZQoJICAgIE5TTG9nIChAIk5PIE1BVENIISIpOwoJcmV0dXJuIDA7Cn0KQGVuZA==