-1

I have a predicate editor that allows the user to use "matches" for RegEx, thus they are entering a text string that is a RexEx used to search. If they enter something wrong, I get:

Can't open pattern U_REGEX_RULE_SYNTAX (string /Volumes/[path to certain file].mp4, pattern (*.abc.*)|(*.abd.*), case 1, canon 2)

How can I validate the string? If I don't and the user saves the file, it quits when trying to resolve this.

Trygve
  • 1,317
  • 10
  • 27

1 Answers1

0

This seems to work:

@try
{
    NSPredicate* predicate = [[self predicateEditor] objectValue];
    [predicate evaluateWithObject:myObject];
}
@catch (NSException* exception)

    NSLog(@"Attempted to create invalid criteria, probably a bad RegEx");
    error = YES;
}
Trygve
  • 1,317
  • 10
  • 27