PHPackages                             ilario-pierbattista/reverse-regex - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. ilario-pierbattista/reverse-regex

ActiveLibrary[Testing &amp; Quality](/categories/testing)

ilario-pierbattista/reverse-regex
=================================

Convert Regular Expressions into text, for testing. Fork of icomefromthenet/reverse-regex

0.6.0(3mo ago)324.5k↑30.9%21MITPHPPHP ^8.1CI passing

Since Oct 17Pushed 3mo agoCompare

[ Source](https://github.com/ilario-pierbattista/ReverseRegex)[ Packagist](https://packagist.org/packages/ilario-pierbattista/reverse-regex)[ Docs](https://github.com/ilario-pierbattista/ReverseRegex)[ RSS](/packages/ilario-pierbattista-reverse-regex/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (11)Versions (20)Used By (1)

ReverseRegex
============

[](#reverseregex)

[![PHP unit](https://github.com/ilario-pierbattista/ReverseRegex/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/ilario-pierbattista/ReverseRegex/actions/workflows/ci.yaml)

> This is a fork of  (that provides `icomefromthenet/reverse-regex`).

Use Regular Expressions to generate text strings can be used in the following situations:

1. Writing test data for web forms.
2. Writing test data for databases.
3. Generating test data for regular expressions.

\##Example

```
use ReverseRegex\Lexer;
use ReverseRegex\Random\SimpleRandom;
use ReverseRegex\Parser;
use ReverseRegex\Generator\Scope;

# load composer
require "vendor/autoload.php";

$lexer = new  Lexer('[a-z]{10}');
$gen   = new SimpleRandom(10007);
$result = '';

$parser = new Parser($lexer,new Scope(),new Scope());
$parser->parse()->getResult()->generate($result,$gen);

echo $result;
```

***Produces***

```
jmceohykoa
aclohnotga
jqegzuklcv
ixdbpbgpkl
kcyrxqqfyw
jcxsjrtrqb
kvaczmawlz
itwrowxfxh
auinmymonl
dujyzuhoag
vaygybwkfm

```

#### Other examples

[](#other-examples)

1. [Australian phone numbers](https://github.com/ilario-pierbattista/ReverseRegex/blob/master/examples/ausphone.php)
2. [Australian postcodes](https://github.com/ilario-pierbattista/ReverseRegex/blob/master/examples/auspostcode.php)
3. [Mobile numbers](https://github.com/ilario-pierbattista/ReverseRegex/blob/master/examples/mobilenumbers.php)

\##Installing

To install use composer

```
composer require ilario-pierbattista/reverse-regex

```

Writing a Regex
---------------

[](#writing-a-regex)

1. Escape all meta-characters i.e. if you need to escape the character in a regex you will need to escape here.
2. Not all meta-characters are suppported see list below.
3. Use `\X{####}` to specify unicode value use `[\X{####}-\X{####}]` to specify range.
4. Unicdoe `\p` not supported, I could not find a port of [UCD](http://www.unicode.org/ucd/) to php, maybe in the future support be added.
5. Quantifiers are applied to left most group, literal or character class.
6. Beware of the `+` and `*` quantifers they apply a possible maxium number of occurances up to `PHP_INT_MAX`.

### Regex Support

[](#regex-support)

   Example   Description   Resulting String     (abcf)   Support literals this would generate string  `abcf`    \\((abcf)\\)   Escape meta characters as you normally would in a regex  `(abcf)`    \[a-z\]   Character Classes are supported  `a`    a{5}   Quantifiers supported always **last** group or literal or character class  `aaaaa`    a{1,5}   Range Quantifiers supported `aa`    a|b|c   Alternation supported pick one of three at random  `b`    a|(y|d){5}   Groups supported with alternation and quantifiers  `ddddd` or `a` or `yyyyy`      \\d   Digit shorthand equ \[0-9\]  `1`    \\w  word character shorthand equ \[a-zA-Z0-9\_\]  `j`    \\W Non word character shorthand equ \[^a-zA-Z0-9\_\]  `j`    \\s White space shorthand ASCII only  ` `    \\S Non White space shorthand ASCII only  `i`    . Dot all ASCII characters  `$`    \* + ? Short hand quantifiers, recommend not use them       \\X{00FF}\[\\X{00FF}-\\X{00FF}\] Unicode ranges      \\xFF\[\\xFF-\\xFF\]  Hex ranges

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance82

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 54.3% of commits — single point of failure

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

Every ~327 days

Recently: every ~268 days

Total

16

Last Release

94d ago

PHP version history (3 changes)v0.1.0.0PHP ^7.1

v0.2.0.0PHP ^7.4 | ^8

0.6.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/907e0b1752610a3cf00ef5d5a1535b02a911647e36a1bea93cc282eeaea6ced5?d=identicon)[ilario-pierbattista](/maintainers/ilario-pierbattista)

---

Top Contributors

[![icomefromthenet](https://avatars.githubusercontent.com/u/746782?v=4)](https://github.com/icomefromthenet "icomefromthenet (25 commits)")[![ilario-pierbattista](https://avatars.githubusercontent.com/u/987038?v=4)](https://github.com/ilario-pierbattista "ilario-pierbattista (19 commits)")[![baschny](https://avatars.githubusercontent.com/u/337581?v=4)](https://github.com/baschny "baschny (1 commits)")[![mhlavac](https://avatars.githubusercontent.com/u/743421?v=4)](https://github.com/mhlavac "mhlavac (1 commits)")

---

Tags

testinggeneratorregextest data

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ilario-pierbattista-reverse-regex/health.svg)

```
[![Health](https://phpackages.com/badges/ilario-pierbattista-reverse-regex/health.svg)](https://phpackages.com/packages/ilario-pierbattista-reverse-regex)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[icomefromthenet/reverse-regex

Convert Regular Expressions into text, for testing

136391.8k12](/packages/icomefromthenet-reverse-regex)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)

PHPackages © 2026

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