BetterRegex

Multi-line regex with comments and functions.

Status: Almost ready

There's a test that has a function handler, but I want to provide a default function handler in the library.

Example

For a more thorough example of inputs & outputs, see test/Regexes.php

<?php
@import(Example.Simple)

Install

It's not on composer or anything yet...

  1. git clone
  2. require both the files in the code dir.

Regex Functions

Syntax

@import(Example.AnimalStuffsReg)
  • Arg list must not include a line break
  • Each argument has whitespace trimmed
  • {{value}}{{..}} is how you declare an array

Function Handler

extend BetterReg, like:

<?php
@import(Example.AnimalStuffsClass)
  • $namespace comes from (new AnimalStuffs($regexes))->parse($regexes['theFuncOne'], 'namespace'). This example doesn't utilize the namespace.

Yields

@import(Example.AnimalStuffsOut)