
T-Regx
Programmer-oriented Regular Expressions library for PHP
- Lightweight
- Reliable
- Secure
- Based on exceptions
Quiz about Vanilla-PHP regular expressions
Super easy, see for yourself how well you know Vanilla-PHP regular expressions. Maybe it turns out you don't need T-Regx, after all :)
Start quizSafeRegex converts warnings to exceptions
SafeRegex watches for warnings, analyzes preg_()
methods return values and looks up preg_last_error()
to validate a call. If it fails, an exception is thrown.
Match details
With pattern()->match()
and pattern()->replace()
, it's trivial to retrieve, iterate, map and filter matches with callbacks and a detailed Match
object.
Checkout the documentation about Match
object with all Match
methods. You can also try it online in 10 seconds - there are examples as well as sandbox for your own tries.
Written with clean design in mind
No Reflection used
, No (...varargs)
, No (boolean arguments, true)
, (No flags, 1)
Based on exceptions!
If any error occurs while using regexp (invalid pattern, malformed UTF8, backtrack limit, nonexistent group, anything!) T-Regx throws an exception, contrary to vanilla-PHP regexp, which usepreg_last_error()
or warnings, which can't be try
/catch
ed.Functional programming
T-Regx utilizes chainable, functional programming with methods like filter()
, map()
, flatMap()
, first()
/findFirst()
, etc.
Apart from standard functional methods, T-Regx provides dedicated methods, suited more for working with string
s and capturing groups from T-Regx, like map()
, mapIfExists()
, mapAndCallback()
, etc.