alaadragneel / regexpressions
Simplify The Regular Expression Proccess
v1.2
2018-09-02 21:12 UTC
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.19.13
- phpunit/phpunit: ^7.4
This package is not auto-updated.
Last update: 2025-03-12 11:30:41 UTC
README
Just For Fun And Learning Proposes
Instlation
$ composer require ''
Use The Expression Class
RegExpressions Has Api For Testing The RegEx And Can Convert Easily To String
<?php use RegExpressions\Expression; class MyClass { public function someMethods() { $regex = Expression::make()->find('www'); if (preg_match((string) $regex, 'www')) { # code... } $regex = Expression::make()->then('google'); if (preg_match((string) $regex, 'google')) { # code... } } }
RegExpressions Has Api For Testing And Returning Boolean Result
<?php use RegExpressions\Expression; class MyClass { public function someMethoods() { $regex = Expression::make()->anything(); if ($regex->test('foo')) { # code... } } }
APis
For Find A String Use
// then() is aliase for find() $regex->find('foo')->then('bar');
For Find Anything Use
$regex->anything();
For Find Anything But Not The Given String Use
$regex->anythingBut('baz');
For Maybe Find Anything Use
// optional() is an alias for maybe() $regex->maybe('baz')->optional('');
For Logging Your Expressions In Run Time Use
$regex->find('foo')->anythingBut('bar')->maybe('baz'); var_dumb($regex->log());