Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 833 Bytes

README.md

File metadata and controls

35 lines (26 loc) · 833 Bytes

Verbal RegEx

Build Status

Just a small mental exercise.

Before running, make sure you have Composer installed.

Then:

  • Clone the repo
  • Run composer install (or composer install --no-dev if you dont't want to run tests)
  • Run the exampe: php example.php
  • ????
  • Profit

Example:

<?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'