PHP library that expands a regular expression into a random string that matches this pattern
You can install the package via composer:
composer require levu42/regexpander
$phoneNumber = Levu42\RegExpander::generate('\d{3}-\d{4}-\d{3}');
echo $phoneNumber;
- Character classes: \d, \D, \s, \S, \w, \W, .
- \d = [0-9]
- \D = [^0-9]
- \s = [ \n\r]
- \S = [^ \n\r]
- \w = [a-zA-Z0-9_]
- \W = [^a-zA-Z0-9_]
- . = [anything]
- Custom character classes, e.g. [0-9a-f], [^x]
- Alternatives: a|b
- Multipliers: a+, a*, a?, a{2,5}
- Subpatterns: (a|b|\s)
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.