T-Regx (a combination of T-Rex and RegExp) is a lightweight Regular Expressions library. Its main features are:
- Descriptive interface (and we mean it)
- Working with and for a developer
- Being explicit (and we mean it too)
- Cleaning the mess after PHP regular expressions API
- Relieving developers from brain strain
Why is descriptive interface so important?
T-Regx' aim is to relieve programmers from brain strain while reading and writing code. Our mission is to make developers write/read a line and immediately go on, without thinking about what it does or what side effects it may cause.
While reading this code...
preg_match($p, $subject, $matches);
...developers must stop for a moment and think:
- Will the
$subjectmatch the pattern
- Will this trigger a warning if I mess up my regexp?
- Will this return
'', if the
- Will this return my value? Or my value nested in arrays?
What should be obvious, is now complicated and causes many questions and assumptions.
While using T-Regx, some things are certain. For example:
$result = pattern($p)->match($subject)->first();
$result must contain the first occurrence. It must contain your value.
It will never contain
false or an empty array.
SubjectNotMatchedException would be thrown in
that case. Even if
first() does return
'', it's only because it supposed to do that; that is "when a pattern matched
a string of length 0".
Also, it will never trigger a warning, but throw
SafeRegexException with a descriptive message.