Installation
T-Regx recommended way of installation is using Composer.
#
PHP 7.1 and laterThe installation of T-Regx is really simple - just add a composer dependency:
T-Regx supports PHP versions: 7.1
, 7.2
, 7.3
, 7.4
, 8.0
, 8.1
, 8.2
.
Scroll to "How to install Composer"
Scroll to "What about /n
modifier added only in 8.2
"?
#
Try T-Regx online (repl.it)Before you install, you can try T-Regx online, right in your browser.
Just visit T-Regx on repl.it, and when it boots up (after about 4 seconds), just click "Run" at the top.
You can log in to repl.it with GitHub account, Google account, Facebook account or regular credentials.
There are two files in the fiddle: You can edit EDIT_HERE.php
as you please;
EXAMPLES.php
contains many basic and complicated examples of T-Regx.
Go to repl.it and run the EXAMPLES.php
or your file in EDIT_HERE.php
:
#
Install composerYou can either download an executable setup from https://getcomposer.org/download/, or use a script to download it, right from your terminal (Windows and Unix).
Once downloaded, install T-Regx.
/n
modifier added in PHP 8.2#
NoAutoCapture While that is true that in vanilla regular expressions in PHP (e.g. preg_match()
) modifier
/n
is only available in PHP 8.2, in T-Regx regular expressions modifier /n
is available in
Pattern
in every supported PHP version.
It's not just an interface trick, the group really isn't being captured.
In the example above, $pattern
will throw MalformedPatternException
, since it tries to
perform matching using group reference \1
, but the group doesn't exist. Modifier /n
can be used with Pattern
in any supported PHP version as if it was implemented natively. Replacing
using withReferences()
also works as expected, so that used references (e.g. $1
) are not
being resolved, unless the group was explicitly named.