kyoushu / regex-builder
A library for building simple regex strings procedurally
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/kyoushu/regex-builder
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2022-02-01 12:44:34 UTC
README
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