kyoushu/regex-builder

This package is abandoned and no longer maintained. No replacement package was suggested.

A library for building simple regex strings procedurally

1.0.0 2015-02-17 17:00 UTC

This package is auto-updated.

Last update: 2022-02-01 12:44:34 UTC


README

Build Status

A library for building simple regex strings procedurally

Example

$regex = RegexBuilder::create()
    ->start()
    ->letter()->repeated()->captureAs('office')
    ->string('_')
    ->number()->repeated(3)->captureAs('id')
    ->end()
    ->getRegex();
    
preg_match($regex, 'OfficeName_123', $match); // Returns TRUE

$regex = RegexBuilder::create()
    ->start()
    ->letter()->repeated()->captureAs('firstWord')
    ->string('_')
    ->matchCaptured('firstWord')
    ->string('_')
    ->number()->repeated()
    ->end()
    ->getRegex();
    
preg_match($regex, 'bar_bar_0293', $match); // Returns TRUE