Skip to content

PHP library that expands a regular expression into a random string that matches this pattern

License

Notifications You must be signed in to change notification settings

levu42/regexpander

Repository files navigation

PHP Regular Expression Expander

Latest Version on Packagist Tests Total Downloads

PHP library that expands a regular expression into a random string that matches this pattern

Installation

You can install the package via composer:

composer require levu42/regexpander

Usage

$phoneNumber = Levu42\RegExpander::generate('\d{3}-\d{4}-\d{3}');
echo $phoneNumber;

Supported regexes

  • 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)

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

PHP library that expands a regular expression into a random string that matches this pattern

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages