Wrapper for PHP regular expression, providing exceptions and error handling.
PHP regular expressions brought up to modern standards.
Installation for PHP 7.1 and later:
composer require rawr/t-regx
You, choose the interface: - I choose to keep PHP methods (but protected from errors):
preg::split()- I choose the modern regex API:
Open T-Regx fiddle and start playing around.
preg::match(), and your method is safe! Arguments and return types remain the same.
Surrounding slashes or tildes (
~patttern~) are not compulsory.
preg::are converted to exceptions.
preg_()can never fail, because it throws
preg_()methods might fail, return
nulland NOT trigger a warning. Separate exception,
SuspectedReturnPregExceptionis then thrown by T-Regx.
No Reflection used,
No (boolean arguments, true),
(No flags, 1),
[No [nested, [arrays]]]
Certain arguments cause fatal errors with
preg_()methods. T-Regx will throw a catchable exception, instead of a Fatal Error.
Using user data (for example with
preg_quote()) isn't always safe with PCRE, as well as just not being that convenient to use. T-Regx provides
Pattern::bind()methods, designed specifically for handling potentially unsafe data.
Continuous integration builds are running for:
T-Regx is MIT licensed.