PHPackages                             levu42/regexpander - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. levu42/regexpander

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

levu42/regexpander
==================

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

v0.0.1(4y ago)183[2 PRs](https://github.com/levu42/regexpander/pulls)MITPHPPHP ^8.0

Since Jan 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/levu42/regexpander)[ Packagist](https://packagist.org/packages/levu42/regexpander)[ Docs](https://github.com/levu42/regexpander)[ RSS](/packages/levu42-regexpander/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

PHP Regular Expression Expander
===============================

[](#php-regular-expression-expander)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c0168f3fb856b3c4322b6a15183a6f2d596febe8f8f107fda1b624327c9e67ce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65767534322f726567657870616e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/levu42/regexpander)[![Tests](https://github.com/levu42/regexpander/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/levu42/regexpander/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/f7805f472b79dbe151a3b0e2a6833bbc072c7862a098266765c4bcd45164b731/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65767534322f726567657870616e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/levu42/regexpander)

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

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require levu42/regexpander
```

Usage
-----

[](#usage)

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

Supported regexes
-----------------

[](#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
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Florian Stascheck](https://github.com/levu42)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1586d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/78662d80c938d6a8675b436e3911f6bb58b9d5da7550c3667c624dd808031ff7?d=identicon)[levu42](/maintainers/levu42)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")[![levu42](https://avatars.githubusercontent.com/u/1259689?v=4)](https://github.com/levu42 "levu42 (3 commits)")

---

Tags

regexregular expressionpatternregexpander

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/levu42-regexpander/health.svg)

```
[![Health](https://phpackages.com/badges/levu42-regexpander/health.svg)](https://phpackages.com/packages/levu42-regexpander)
```

###  Alternatives

[composer/pcre

PCRE wrapping library that offers type-safe preg\_\* replacements.

693313.8M34](/packages/composer-pcre)[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k17.1M59](/packages/spatie-regex)[league/pipeline

A plug and play pipeline implementation.

1.0k16.0M74](/packages/league-pipeline)[gherkins/regexpbuilderphp

PHP port of thebinarysearchtree/regexpbuilderjs

1.4k163.0k1](/packages/gherkins-regexpbuilderphp)[getsolaris/laravel-make-service

A MVCS pattern create a service command for Laravel 5+

81161.3k](/packages/getsolaris-laravel-make-service)[cytopia/awesome-ci

Lot's of tools for git, file and static source code analysis.

3386.4k](/packages/cytopia-awesome-ci)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
