1. Go to this page and download the library: Download gherkins/regexpbuilderphp 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/ */
gherkins / regexpbuilderphp example snippets
use Gherkins\RegExpBuilderPHP;
$builder = new RegExpBuilder();
$regExp = $builder
->multiLine()
->globalMatch()
->min(1)->max(10)->anythingBut(" ")
->anyOf(array(".pdf", ".doc"))
->getRegExp();
$text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy SomeFile.pdf eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam
et justo duo dolores et ea rebum. doc_04.pdf Stet clita kasd File.doc.'
$matches = $regExp->findIn($text);
//true
($matches[0] === "SomeFile.pdf");
($matches[1] === "doc_04.pdf");
($matches[2] === "File.doc");
$regExp = $builder
->min(1)
->max(10)
->digits()
->getRegExp();
$text = "98 bottles of beer on the wall";
$text = $regExp->replace(
$text,
function ($match) {
return (int)$match + 1;
}
);
//true
("99 bottles of beer on the wall" === $text);