1. Go to this page and download the library: Download rawr/t-regx library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rawr / t-regx example snippets
$pattern = Pattern::of("ups"); // pattern("ups") also works
$matcher = $pattern->match('yay, ups');
foreach ($matcher as $detail) {
$detail->text(); // (string) "ups";
$detail->offset(); // (int) 0
}
if (!$matcher->test()) {
echo "No occurrances found";
} else {
echo "Found {$matcher->count()} occurrences";
}
$pattern = Pattern::of("ups"); // pattern("ups") also works
$matcher = $pattern->match('yay, ups');
if (!$matcher->test()) {
echo "Unmatched subject :/";
}
foreach ($matcher as $detail) {
$detail->text(); // (string) "ups";
$detail->offset(); // (int) 0
}
$pattern->replace('well, ups')->with('heck') // (string) "well, heck";