It's the first time trying to use Regular Expression. I am trying to match Australian Post code(i.e 4 digit) , but my noOFMatches gets no . of digits +1 (9 in this case)in it. I know it's something silly that i cannot figure out. Pls suggest. I feel if I pass 4 digit nos. in postcode then noOfMatches should get 1 . is that correct?
NSString *postCode = @"12345676";
NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:@"(|d{4})" options:NSRegularExpressionCaseInsensitive error:nil];
int noOfMatches = [ regularExpression numberOfMatchesInString:field.text options:0 range:NSMakeRange(0, [postCode length])];