I want users to be able to provide relatively simple patterns for matching (for now) different kinds of IDs. I need to evaluate those patterns server side, potentially against a big number of short strings.
The obvious solution is to user regular expressions, but that seems somewhat dangerous, compare https://stackoverflow.com/a/4289936/1239832. Catastrophic backtracking can use a lot of CPU and RAM, which amounts to a DoS vector.
I would be content with something a lot simpler than full PCRE, perhaps something like "posessive" regular expressions with no backtracking. Are there libraries that can do this? PHP would be ideal, but I'd be willing to port, if the code is not too complex.