I have text that may have parentheses, brackets, in it, and a substring that has the same text. How can I get these texts to match up via regular expression, but with case insensitivity?
NSError* error = nil; NSString* text = @"Hello (extreme elevation) - some longer string"; NSString* obj = @"hello (extreme elevation)"; NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:obj options:NSRegularExpressionCaseInsensitive error:&error]; NSArray* matches = [regex matchesInString:text options:0 range:NSMakeRange(0, text.length)];
This doesn't match anything, and even if Obj has the hello capitalized, it won't match via regex, but will match via NSString rangeOfString. I want to be able to match obj to text in this case, and other cases where I may have brackets, like:
NSString* text = @"Hello [extreme elevation]"; NSString* obj = @"hello [extreme elevation]";