I've separated the library into
SafeRegex is an exact copy of all
preg_replace()). They're used like this:
I didn't want to use namespaces (like
\SafeRegex\preg_match) because that would
mean the programmers reading the code would have to check the imported namespaces every time they look at the code.
With double colon
:: it's obvious. Read on, for more details.
preg::*() methods analyse warnings, return types of methods and result of
preg_last_error(), and if they find that
the pattern or subject failed in some way, they throw an exception, instead of a warning or returning
I want developers to stop worrying about what might cause a bug, when they use regular expressions, and just
focus on the creative part. I want them to feel: "This code has to work, it would throw an exception otherwise".
CleanRegex is what it was - the API part, that's using
SafeRegex never to care about warnings or returning
That's it for today! :)