Library for PHP regular expression, providing high-level API.
PHP regular expressions brought up to modern standards.
Installation for PHP 7.1 and later (PHP 8 as well):
composer require rawr/t-regx
Current development priorities, regarding release of 1.0:
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.
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.
Pattern::format()allows converting user-supplied masks into full-fledged patterns safely.
Surrounding slashes or tildes (
~patttern~) are not compulsory.
preg_()methods don't make
preg_last_error()to return error.
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.
T-Regx is MIT licensed.