I have a regex to check Max 70 alphanumeric characters and special characters: ' / \\ - ; @ and space for which i am using the following regex pattern -
^[a-zA-Z0-9,.-\s'\\\/@]{0,70}$
Please Note: testing this in https://regex101.com works perfectly fine
And the following code to match it with string -
NSString *String = area@123\\
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[a-zA-Z0-9,.-\s'\\\/@]{0,70}$" options:NSRegularExpressionCaseInsensitive error:&error];
NSAssert(regex, @"Unable to create regular expression");
NSRange textRange = NSMakeRange(0, string.length);
NSRange matchRange = [regex rangeOfFirstMatchInString:string options:NSMatchingReportProgress range:textRange];
Initially it was showing escape sequence error for which I changed the pattern to - ^[a-zA-Z0-9,.-\\s'\\\\//@]{0,70}$
And now its resulting in crash with message-
Assertion failure in +[UMValidations validateString:withPattern:]
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to create regular expression
Now what wrong is happening when this pattern works great on the regex tester.