Skip to content

t-regx/functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

T-Regx

Build status

Regex | Set of function helpers

PHP Version PHP Version PHP Version

A set of helper functions with modern interface for built-in PHP preg_ functions. Revamped approach, all the goodies extracted from T-Regx library, waste removed.

Buy me a coffee!

Examples

Testing string subject against regex pattern:

re_test('[a-z]+', 'word');
// bool (true)

re_test('[a-z]+', 'WORD', modifiers:'i');
// bool (true)

Helpful error message for syntax errors in regex patterns:

try {
    re_test('[a-z', 'word');
} catch (\Regex\MalformedRegex $exception) {
    // 'missing terminating ] for character class'
}

Exceptions with positions of syntax errors in the pattern:

re_test('(Foo:[a-z]))\w+', 'word');
Regex\MalformedRegex: unmatched closing parenthesis

(Foo:[a-z]))\w+
           ^

Literal values in patterns:

re_test('^foo' . \preg_quote('$12') . '$', 'foo:$12'); // won't work
re_test(re_quote('^foo@$', ['$12']),       'foo:$12'); // inject literal values into @ placeholders

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages