PHPackages                             icomefromthenet/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. icomefromthenet/reverse-regex

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

icomefromthenet/reverse-regex
=============================

Convert Regular Expressions into text, for testing

v0.1.0.0(7y ago)136386.7k—0%38[4 issues](https://github.com/icomefromthenet/ReverseRegex/issues)[4 PRs](https://github.com/icomefromthenet/ReverseRegex/pulls)12MITPHPPHP ^7.1

Since Oct 17Pushed 8mo ago8 watchersCompare

[ Source](https://github.com/icomefromthenet/ReverseRegex)[ Packagist](https://packagist.org/packages/icomefromthenet/reverse-regex)[ Docs](http://github.com/icomefromthenet/ReverseRegex)[ RSS](/packages/icomefromthenet-reverse-regex/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (12)Used By (12)

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

[](#reverseregex)

[![Build Status](https://camo.githubusercontent.com/9a4e0aa470badc8e8e7f69db199d3948f5e5f2b8b56cd20dd3297dd73c3d420f/68747470733a2f2f7472617669732d63692e6f72672f69636f6d6566726f6d7468656e65742f5265766572736552656765782e706e67)](https://travis-ci.org/icomefromthenet/ReverseRegex)

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

1. Wrting 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/icomefromthenet/ReverseRegex/blob/master/examples/ausphone.php)
2. [Australian postcodes](https://github.com/icomefromthenet/ReverseRegex/blob/master/examples/auspostcode.php)
3. [Mobile numbers](https://github.com/icomefromthenet/ReverseRegex/blob/master/examples/mobilenumbers.php)

\##Installing

To install use composer

```
{
  "require" : {
	"icomefromthenet/reverse-regex" : "dev-master"
    }
}
```

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

46

—

FairBetter than 93% of packages

Maintenance42

Moderate activity, may be stable

Popularity51

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.2% 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 ~236 days

Recently: every ~422 days

Total

10

Last Release

2834d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/746782?v=4)[Lewis Dyer](/maintainers/icomefromthenet)[@icomefromthenet](https://github.com/icomefromthenet)

---

Top Contributors

[![icomefromthenet](https://avatars.githubusercontent.com/u/746782?v=4)](https://github.com/icomefromthenet "icomefromthenet (25 commits)")[![mhlavac](https://avatars.githubusercontent.com/u/743421?v=4)](https://github.com/mhlavac "mhlavac (1 commits)")

---

Tags

testinggeneratorregextest data

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[behat/mink

Browser controller/emulator abstraction for PHP

1.6k86.1M606](/packages/behat-mink)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

57026.3M456](/packages/dg-bypass-finals)[breerly/factory-girl-php

Fixture replacement for focused and readable tests - A PHP port of Thoughtbot's Ruby Factory Girl

111242.8k2](/packages/breerly-factory-girl-php)[trappar/alice-generator

Automatically generates alice fixture based on a set of objects

52185.4k1](/packages/trappar-alice-generator)[webfactory/doctrine-orm-test-infrastructure

Provides utils to create a test infrastructure for Doctrine 2 entities.

2052.9k1](/packages/webfactory-doctrine-orm-test-infrastructure)

PHPackages © 2026

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