<?php require_once realpath(__DIR__ . '/../vendor/autoload.php'); use SelvinOrtiz\Utils\Flux\Flux; use SelvinOrtiz\Utils\Flux\Helper; // The subject string (URL) $str = 'http://www.selvinortiz.com'; // Building the pattern (Fluently) $flux = Flux::getInstance()->startOfLine()->find('http')->maybe('s')->then('://')->maybe('www.')->anythingBut('.')->either('.co', '.com')->ignoreCase()->endOfLine(); // Output the Flux instance Helper::dump($flux); // Output the fluently built pattern (@see /src/SelvinOrtiz/Utils/Flux/Helper) Helper::msg($flux); // Inspect the results Helper::msg($str); Helper::msg($flux->match($str) ? 'matched' : 'unmatched'); Helper::msg($flux->replace('https://$5$6', $str)); Helper::msg(Flux::getInstance()->word()->length(1)); Helper::msg(Flux::getInstance()->then('hello')->length(5)); //-------------------------------------------------------------------------------- // EOF //--------------------------------------------------------------------------------
<?php require_once realpath(__DIR__ . '/../vendor/autoload.php'); use SelvinOrtiz\Utils\Flux\Flux; use SelvinOrtiz\Utils\Flux\Helper; // The subject string (Phone) $str = '(612) 424-0013'; // Building the pattern (Fluently) $flux = Flux::getInstance()->startOfLine()->find('(')->digits(3)->then(')')->maybe(' ')->digits(3)->anyOf(' -')->digits(4)->endOfLine(); // Output the Flux instance Helper::dump($flux); // Output the fluently built pattern (@see /src/SelvinOrtiz/Utils/Flux/Helper) Helper::msg($flux); // Inspect the results Helper::msg($str); Helper::msg($flux->match($str) ? 'matched' : 'unmatched'); Helper::msg($flux->replace('$2.$5.$7', $str)); //-------------------------------------------------------------------------------- // EOF //--------------------------------------------------------------------------------
<?php require_once realpath(__DIR__ . '/../vendor/autoload.php'); use SelvinOrtiz\Utils\Flux\Flux; use SelvinOrtiz\Utils\Flux\Helper; // The subject string (Date) $str = 'Monday, Jul 22, 2013'; // Building the pattern (Fluently) $flux = Flux::getInstance()->startOfLine()->word()->then(', ')->letters(3)->then(' ')->digits(1, 2)->then(', ')->digits(4)->endOfLine(); // Output the Flux instance Helper::dump($flux); // Output the fluently built pattern (@see /src/SelvinOrtiz/Utils/Flux/Helper) Helper::msg($flux); // Inspect the results Helper::msg($str); Helper::msg($flux->match($str) ? 'matched' : 'unmatched'); Helper::msg($flux->replace('$3/$5/$7', $str)); //-------------------------------------------------------------------------------- // EOF //--------------------------------------------------------------------------------