assert icon indicating copy to clipboard operation
assert copied to clipboard

Add validRegexPattern assertions

Open zlodes opened this issue 1 year ago • 1 comments

Why?

  1. PHP functions working with regex (preg_match, preg_replace, etc.) work in legacy way — they just return false instead of throwing exception.
  2. The way to check if the string is regex is quite hacky, so, would be great to hide the check implementation somewhere.

References

  1. https://stackoverflow.com/a/8825096/3578207

zlodes avatar Oct 20 '24 15:10 zlodes

I see that some tests failed. Fixing. 🤔

zlodes avatar Oct 20 '24 16:10 zlodes

@shadowhand Hello mate!

As I can see, the latest release of the package was in 2022. Is there any plans for the next release?

zlodes avatar Nov 23 '24 16:11 zlodes

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.

shadowhand avatar Dec 02 '25 13:12 shadowhand

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.

zlodes avatar Dec 02 '25 14:12 zlodes

My suggestion for those alternative packages was for your own code, not to be used with this project.

shadowhand avatar Dec 02 '25 15:12 shadowhand