Advertisement
Guest User

regex

a guest
Jan 4th, 2014
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Without this library
  2. NSString* string = @"I have 2 dogs.";
  3. NSRegularExpression *regex = [NSRegularExpression regular ExpressionWithPattern:@"\\d+" options:NSRegularExpressionCaseInsensitive error:&error];
  4. NSTextCheckingResult *match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])];
  5. BOOL isMatch = match != nil;
  6.  
  7. // With this library
  8. BOOL isMatch = [@"I have 2 dogs." isMatch:RX(@"\\d+")];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement