2017 © Pedro Peláez
 

library hexpress

hexpress is a PHP library that human way to define regular expressions

image

sizuhiko/hexpress

hexpress is a PHP library that human way to define regular expressions

  • Sunday, May 29, 2016
  • by sizuhiko
  • Repository
  • 3 Watchers
  • 39 Stars
  • 206 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 16 % Grown

The README.md

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

hexpress

hexpress is a PHP library that human way to define regular expressions, (*2)

hexpress is ported from Ruby's hexpress., (*3)

The hexpress is another take at the concept of "Verbal Hexpressions"., (*4)

hexpress requires PHP >= 5.5, (*5)

Using

``` php use Hexpress\Hexpress;, (*6)

$pattern = (new Hexpress()) ->start("http") ->maybe("s") ->with("://") ->maybe(function($hex) { $hex->words()->with("."); }) ->find(function($hex) { $hex->matching(function($hex) {$hex->word()->with("-");})->many(); }) ->has(".") ->either(["com", "org"]) ->maybe("/") ->ending();, (*7)


After `use Hexpress\Hexpress` you'll have access to the Hexpress class, which allows you to chain methods to build up a regex pattern. You can see this pattern by calling either `Hexpress#__toString()` or `Hexpress#toRegExp`: ``` php echo $pattern; #=> "^https?\:\/\/(?:(?:\w)+\.)?([\w\-]+)\.(?:com|org)\/?$" echo $pattern->toRegExp(); #=> "/^https?\:\/\/(?:(?:\w)+\.)?([\w\-]+)\.(?:com|org)\/?$/"

You can even do advanced composure of multiple patterns:, (*8)

``` php $protocol = (new Hexpress())->start("http")->maybe("s")->with("://"); $tld = (new Hexpress())->with(".")->either(["org", "com", "net"]); $link = (new Hexpress())->has($protocol)->find(function($hex) {$hex->words();})->including($tld);, (*9)

echo $link; #=> "^https?:\/\/((?:\w)+).(?:org|com|net)", (*10)


Hexpressions are very flexible. ## TODO - PHP Document and API reference - lookahead assertions - lookbehind assertions - back reference - conditional subpattern - once-only subpattern - Internal option setting ## Installing Add this line to your application's composer.json: ``` json "require": { "sizuhiko/hexpress": ">=1.0" },

And then execute:, (*11)

$ composer install

Or install it yourself as:, (*12)

$ composer require "sizuhiko/hexpress:>=1.0"

Contributing to this Library

Please feel free to contribute to the library with new issues, requests, unit tests and code fixes or new features. If you want to contribute some code, create a feature branch from develop, and send us your pull request., (*13)

The Versions

29/05 2016

dev-master

9999999-dev

hexpress is a PHP library that human way to define regular expressions

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Avatar sizuhiko

29/05 2016

dev-develop

dev-develop

hexpress is a PHP library that human way to define regular expressions

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Avatar sizuhiko

29/05 2016

v0.1.1

0.1.1.0

hexpress is a PHP library that human way to define regular expressions

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Avatar sizuhiko

20/09 2015

v0.1.0

0.1.0.0

hexpress is a PHP library that human way to define regular expressions

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Avatar sizuhiko