PHP code example of multihanded / regent
1. Go to this page and download the library: Download multihanded/regent 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/ */
multihanded / regent example snippets
echo Regent::startsWith()
->openAnyOf()
->range('a', 'z')
->digit()
->closeAnyOf()
->between(5, 10)
->endsWith()
->caseless(); // ~^[a-z\d]{5,10}$~i
// regex to search for email in text
$anyOf = Regent::openAnyOf()
->range('a', 'z')
->range(0, 9)
->addPattern('_-')
->closeAnyOf()->pattern;
$startsWith= Regent::openGroup()
->addPattern($anyOf)
->oneOrMore()
->addPattern('.', true)
->closeGroup()->pattern;
$secondGroup = Regent::openGroup()
->addPattern('.', true)
->addPattern($anyOf)
->oneOrMore()
->closeGroup()->pattern;
$firstSegment = Regent::zeroOrMore()
->addPattern($anyOf)
->oneOrMore()
->addPattern('@')
->addPattern($anyOf)
->oneOrMore()->pattern;
$endWith = Regent::zeroOrMore()
->addPattern('.', true)
->openAnyOf()
->range('a', 'z')
->closeAnyOf()
->between(2, 6)->pattern;
echo Regent::startsWith($startsWith)
->addPattern($firstSegment)
->addPattern($secondGroup)
->endsWith($endWith)
->caseless(); // ~^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$~i
use MultihandED\Regent\Facades\Regent;
public function boot()
{
Regent::setDelimiterDefault('%');
}