Objective-C Regex Categories

MIT License
Objective-C
iOS

1 image

Author

Description

This project is a collection of objective-c categories for NSRegularExpression and NSString that make usage easier and more concise.

//Using NSRegularExpression
NSString* string = @"I have 2 dogs.";
NSRegularExpression *regex = [NSRegularExpression
    regularExpressionWithPattern:@"\\d+"
    options:NSRegularExpressionCaseInsensitive
    error:&error];

NSTextCheckingResult *match = [regex firstMatchInString:string
     options:0
     range:NSMakeRange(0, [string length])];

BOOL isMatch = match != nil;

// Using this library
BOOL isMatch = [@"I have 2 dogs." isMatch:RX(@"\\d+")];

.

Learn more at: https://github.com/bendytree/Objective-C-RegEx-Categories

Tags