Just a small mental exercise.
Before running, make sure you have Composer installed.
Then:
- Clone the repo
- Run
composer install
(orcomposer install --no-dev
if you dont't want to run tests) - Run the exampe:
php example.php
- ????
- Profit
<?php
use Rb\VerbalRegex\Statement;
$statement = new Statement();
$statement->find('http')
->maybe('s')
->then('://')
->maybe('www.')
->endsWith()
->anythingBut(' ', 'domain'); // 2nd argument is the (optional) name for the match
$matches = $statement->match('http://www.google.com');
echo $matches['domain']; // echoes 'google.com'