cawa0505 / verbal-expressions-php
PHP Regular expressions made easy.
v1.0.0
2019-04-06 22:24 UTC
Requires
- php: >=5.5.9
- friendsofphp/php-cs-fixer: ^2.14
Requires (Dev)
- phpunit/phpunit: * >=4
Suggests
- friendsofphp/php-cs: A tool to automatically fix PHP code style
This package is auto-updated.
Last update: 2024-12-07 10:29:55 UTC
README
- Forked from the original PHP Verbal Expressions library.
- Ported from VerbalExpressions.
Verbal Expressions is a PHP library that helps to construct hard regular expressions.
Examples
$regex = new VerbalExpressions; $regex->startOfLine() ->then("http") ->maybe("s") ->then("://") ->maybe("www.") ->anythingBut(" ") ->endOfLine(); if ($regex->test("https://github.com/")) { echo "valid url"; } else { echo "invalid url"; } if (preg_match($regex, 'http://github.com')) { echo 'valid url'; } else { echo 'invalid url'; } echo "<pre>". $regex->getRegex() ."</pre>"; echo $regex->clean(array("modifiers" => "m", "replaceLimit" => 4)) ->find(' ') ->replace("This is a small test http://somesite.com and some more text.", "-");
Other Implementations
You can see an up to date list of all ports on VerbalExpressions.github.io.
Building the project and running the tests
All tests are written using PHPUnit. Please ensure that you have it installed and run all tests before contributing.