1. Go to this page and download the library: Download mcustiel/php-simple-regex 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/ */
mcustiel / php-simple-regex example snippets
use Mcustiel\PhpSimpleRegex\Executor as RegexExecutor;
$regexFacade = new RegexExecutor();
try {
$result = $regexFacade->getAllMatches('/\d+/', 'ab12cd34ef56');
echo 'Number of matches: ' . $result->getMatchesCount() . PHP_EOL; // Prints 3
echo 'First match: ' . $result->getMatchAt(0)->getFullMatch() . PHP_EOL; // Prints 12
// Iterate over results
foreach ($result as $index => $match) {
echo "Match at index {$index} is " . $match->getFullMatch() . PHP_EOL;
}
} catch (\Exception $e) {
echo 'An error occurred executing getAllMatches';
}