Hi everyone,
I stumbled across the following issue, proposing to add a way to validate
regex. [1]
There is currently no way of knowing if a regex pattern is valid, apart
from writing clunky code. [2]
Two propositions emerged from the issue: either create a dedicated
"preg_validate()" function, or add a new flag to "filter_var()", namely
FILTER_VALIDATE_REGEX_PATTERN.
I would be in favor of the latter. The approach and implementation would
surely be simpler. I don't feel like we should do advanced error
management. Knowing if a pattern is valid or not would suffice for the vast
majority of cases.
I don't think the second approach would require an RFC. Christoph thinks
that this should at least be announced on the mailing list, so here we are.
Looking forward to your feedback.
— Alexandre Daubois
[1] https://github.com/php/php-src/issues/9289
[2] https://stackoverflow.com/questions/4440626/how-can-i-validate-regex