Programmer-oriented Regular Expressions wrapper library for PHP
- 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 quiz
SafeRegex 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 your subject against a pattern
pattern()->test() to check whether your subject matches a given regular expression.
In this case whether
pattern()->replace(), it's trivial to retrieve, iterate, map and filter matches with callbacks and a detailed
It doesn't matter whether the pattern was constructed with
Detail is always the same.
Checkout the documentation about
Detail, which describes every
Uniform API for matching and replacing
pattern()->replace() callbacks receive the same interface
Detail used for matching and replacing has exactly the same methods and returns the same values for given
You can also try it online in 10 seconds - there are examples in the as sandbox for your own tries.
With Prepared Patterns you can safely build your regular expressions, without worrying about it becoming malformed or dangerous.
T-Regx provides a wide variety of prepared patterns, for different needs:
For constant patterns use
Pattern::of() or simply
Different ways of instantiating Patterns
Regardless of whether you build your pattern using
pattern() helper, or maybe using prepared patterns like
Pattern::alternate(), the interface of
Pattern is the same.
Additionally, building patterns using
Pattern::template() also share the same
Try T-Regx online
Before you install, you can try T-Regx online, right in your browser.
You can use repl.it using your GitHub account, Facebook account or Google account -T-Regx on repl.it
Written with clean design in mind
T-Regx utilises well designed interfaces, so your IDE will aid you as you type! We follow real SOLID and OOP.