Is there a regexp to check if a string is a valid php regexp ?
In the back office of my application, the administrator define the data type and he can define a pattern as a regexp. For example /^[A-Z][a-zA-Z]+[a-z]$/ and in the front office, i use this pattern for validate user entries.
In my code i use the PHP preg_match function
preg_match($pattern, $user_entries);
the first argument must be a valid PHP regexp, how can i be sure that $pattern is a valid regexp since it a user entrie in my back office.
Any idea ?
.*.*.*.*.*.*.*^will keep your regex engine busy for a long time on any string that's longer than a few characters (>590.000 iterations when applied to1111111111111111, for example)./emodifier the replacement will be evaluated as PHP code if the regex is used withpreg_replace.