Escape invalid regexes in regex matcher