2017 © Pedro Peláez
 

library rebuilder

REBuilder is a PHP library to build and parse regular expressions

image

mck89/rebuilder

REBuilder is a PHP library to build and parse regular expressions

  • Thursday, September 15, 2016
  • by mck89
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

REBuilder

REBuilder is a PHP 5.3+ library to build and parse regular expressions, (*1)

Installation

Include the following requirement to your composer.json:, (*2)

{
    "require": {
        "mck89/rebuilder": "dev-master"
    }
}

Run composer install and include the autoloader:, (*3)

require_once "vendor/autoload.php";

Parse

REBuilder's parser builds a tree structure starting from a regular expression. For example this code:, (*4)

//Parse the regular expression
$regex = REBuilder\REBuilder::parse("/parse\s+me/");

Generates this structure:, (*5)

REBuilder\Pattern\Regex
    getStartDelimiter() => "/"
    getEndDelimiter() => "/"
    getChildren() => array(
        REBuilder\Pattern\Char
            getChar() => "parse"

        REBuilder\Pattern\GenericCharType
            getIdentifier() => "s"
            getRepetition() => REBuilder\Pattern\Repetition\OneOrMore

        REBuilder\Pattern\Char
            getChar() => "me"
    )

Build

REBuilder allows you to build regular expressions with object oriented PHP:, (*6)

//Create an empty regular expression object
$regex = REBuilder\REBuilder::create();

$regex->addCharAndContinue("parse")
      ->addGenericCharType("s")
          ->setRepetition("+")
          ->getParent()
      ->addCharAndContinue("me");

echo $regex->render(); //"/parse\s+me/"

The Versions

15/09 2016

dev-master

9999999-dev

REBuilder is a PHP library to build and parse regular expressions

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Marco Marchiò