Recommend this page to a friend! |
Classes of Patrick Van Bergen | PHP Regex Builder | README.md | Download |
|
Downloadr - Regular Expression Builder (PHP)r Is a PHP library to build regular expressions. It is written for PHP 5 and it handles PCRE patterns in a fairly advanced level, but it does not cover the complete specification. Why?There are several reasons why one would want build a regular expression with code, rather than to write it down directly: * For non-experts, the expression is easier to read * It is a handy tool to compose an expression at runtime, depending on different variables and rules * There is no need to escape characters, which is always a tricky part * No need to look up the syntax of little used constructs: the fluid interface allows for auto completion ExamplesThese examples can also be found in the file 'examples.php'. Full string match
Alternate texts
Characters
Nested groups
Assertions
Quantifiers
Named blocks, alternate delimiters (#)
Multiline expression
Look behind, look ahead
The old way is way easier!Then write parts of the expression in the old style:
CreditsThe credits for the idea of creating a regular expression builder go to VerbalExpressions. It is a fascinating idea and I wanted to see how far it could go. I chose a different type of implementation based on nested fluid interface calls. |