PHP code example of ldrahnik / regexp
1. Go to this page and download the library: Download ldrahnik/regexp 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/ */
ldrahnik / regexp example snippets
/** @var \regexp\Regexp @inject */
private $regexp;
public function __construct(regexp\Regexp $regexp)
{
$this->regexp = $regexp;
}
public function createComponentForm()
{
$form = new Nette\Application\UI\Form();
$form->addText('twitter', 'Twitter username')
->setDefaultValue('@')
->addCondition(Form::FILLED)
->addRule(Form::PATTERN, 'Please enter twitter username, for example: @username',
$this->regexp->getTwitterUsername());
...
// $this->regexp->getRegularExpression('twitterUsername'));
// equivalent of that expression is
// $this->regexp->getTwitterUsername();
}
....