Add validRegexPattern assertions
Why?
- PHP functions working with regex (
preg_match,preg_replace, etc.) work in legacy way — they just returnfalseinstead of throwing exception. - The way to check if the string is regex is quite hacky, so, would be great to hide the check implementation somewhere.
References
- https://stackoverflow.com/a/8825096/3578207
I see that some tests failed. Fixing. 🤔
@shadowhand Hello mate!
As I can see, the latest release of the package was in 2022. Is there any plans for the next release?
I think there are better regex wrappers that check for failures, such as:
- https://packagist.org/packages/composer/pcre
- https://packagist.org/packages/rawr/t-regx
- and others...
Calling a function with @ suppression is a style I don't want to adopt in this package.
I think there are better regex wrappers that check for failures, such as:
I agree that the current approach doesn't look ideal, but it's the only native way to validate a regex. I'm not sure it's a good idea to introduce additional dependencies into such a lightweight package.
If you're fine with it, I can add equivalent methods using one of the packages you mentioned.
My suggestion for those alternative packages was for your own code, not to be used with this project.