2017 © Pedro Peláez
 

library reverse-regex

Convert Regular Expressions into text, for testing

image

icomefromthenet/reverse-regex

Convert Regular Expressions into text, for testing

  • Monday, January 18, 2016
  • by icomefromthenet
  • Repository
  • 8 Watchers
  • 95 Stars
  • 41,070 Installations
  • PHP
  • 6 Dependents
  • 1 Suggesters
  • 18 Forks
  • 3 Open issues
  • 10 Versions
  • 14 % Grown

The README.md

ReverseRegex

Build Status, (*1)

Use Regular Expressions to generate text strings can be used in the following situations:, (*2)

  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, (*3)

jmceohykoa
aclohnotga
jqegzuklcv
ixdbpbgpkl
kcyrxqqfyw
jcxsjrtrqb
kvaczmawlz
itwrowxfxh
auinmymonl
dujyzuhoag
vaygybwkfm

Other examples

  1. Australian phone numbers
  2. Australian postcodes
  3. Mobile numbers

Installing

To install use composer, (*4)

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

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

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

The Versions

18/01 2016

dev-master

9999999-dev http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

The Development Requires

testing generator regex test data

18/01 2016

v0.0.6.3

0.0.6.3 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

The Development Requires

testing generator regex test data

31/12 2013

v0.0.6.2

0.0.6.2 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

The Development Requires

testing generator regex test data

31/12 2013

v0.0.6.1

0.0.6.1 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

The Development Requires

testing generator regex test data

30/12 2013

v0.0.6

0.0.6.0 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

The Development Requires

testing generator regex test data

08/01 2013

v0.0.5

0.0.5.0 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

testing generator regex test data

22/11 2012

v0.0.4

0.0.4.0 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

testing generator regex test data

22/10 2012

v0.0.3

0.0.3.0 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

testing generator regex test data

18/10 2012

v0.0.2

0.0.2.0 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

testing generator regex test data

17/10 2012

v0.0.1

0.0.1.0 http://github.com/icomefromthenet/ReverseRegex

Convert Regular Expressions into text, for testing

  Sources   Download

MIT

The Requires

 

testing generator regex test data