#
Comparison table of plain PHP and T‑RegxHere's a little table of some of the differences between the behaviour of plain PHP preg_match()
preg_match_all()
preg_replace()
preg_split()
preg_grep()
preg_filter()
preg_match()
methods and T‑Regx API. This table intentionally shows the corner-cases and edge-cases, because that's the best way to illustrate differences between T‑Regx and vanilla-PHP.
#
SafeRegex compared to PHPTable presents the most important differences in error handling and general maturity between T‑Regx preg::match()
preg::match_all()
preg::replace()
preg::split()
preg::grep()
preg::filter()
preg::match()
methods and PHP preg_match()
preg_match_all()
preg_replace()
preg_split()
preg_grep()
preg_filter()
preg_match()
methods.
Using na invalid pattern(eg. /unclosed[A-/ ) | |
| |
T-Regx throws MalformedPatternException with descriptive message | |
Corrupted subject(eg. malformed utf-8 sequence) | |
| |
T-Regx throws SubjectEncodingException with descriptive message | |
Using an overly complex pattern(eg. containing ?R ) | |
| |
T-Regx throws RecursionException with descriptive message | |
Returning an invalid replacement value | |
| |
T-Regx throws InvalidReplacementException with descriptive message |
#
CleanRegex compared PHPThis table shows difference between higher-level CleanRegex API pattern()
and SafeRegex preg::match()
preg::match_all()
preg::replace()
preg::split()
preg::grep()
preg::filter()
preg::match()
methods (which share the same interface as preg_match()
preg_match_all()
preg_replace()
preg_split()
preg_grep()
preg_filter()
preg_match()
).
Using an invalid capturing group name(eg. name "!@#$" or index -2 ) | |
Actually tries to get the groupDepending on PHP settings, either returns null and/or issues a warning | |
T-Regx throws \InvalidArgumentException with descriptive message | |
Using a nonexistent group(group name typo, group deleted) | |
Actually tries to get the groupDepending on PHP settings, either returns null and/or issues a warning | |
T-Regx throws NonexistentGroupException with descriptive message | |
Using an unmatched optional group(conditional group, unmatched by subject) | |
Actually tries to get the groupDepending on PHP settings, either returns null and/or issues a warning | |
T-Regx throws GroupNotMatchedException with descriptive message | |
Offsets in UTF-8, for example for "18€" | |
5 bytesPHP offsets are in bytes | |
| |
Worst case complexity | |
string /null and int preg_match_all() with PREG_OFFSET_CAPTURE | |
string[] array of strings | |
Possible outcomes when testing a subject | |
| |
|