PHPackages                             sizuhiko/hexpress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sizuhiko/hexpress

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sizuhiko/hexpress
=================

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

v0.1.1(9y ago)41309MITPHPPHP &gt;=5.5

Since Sep 20Pushed 9y ago4 watchersCompare

[ Source](https://github.com/sizuhiko/hexpress)[ Packagist](https://packagist.org/packages/sizuhiko/hexpress)[ RSS](/packages/sizuhiko-hexpress/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

[![Build Status](https://camo.githubusercontent.com/3727202bada0ba118c7dab13ac272dbb56fca90a0125b99c988493e9e1bd43e4/68747470733a2f2f7472617669732d63692e6f72672f73697a7568696b6f2f68657870726573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sizuhiko/hexpress) [![Coverage Status](https://camo.githubusercontent.com/3b753a7dee3071ebfdd1d22800885d734ab6382683a3457ed1391af01e597430/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f73697a7568696b6f2f68657870726573732f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/sizuhiko/hexpress?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/49aea433e0b1004b20265ac0ec372f879884f2fadd25a5c3b7152b9c37716c78/68747470733a2f2f706f7365722e707567782e6f72672f73697a7568696b6f2f68657870726573732f762f737461626c65)](https://packagist.org/packages/sizuhiko/hexpress) [![Total Downloads](https://camo.githubusercontent.com/2fc8393f4905a31fb8368bd4dad4b1381acf2506830cb05125cbbda95ab90184/68747470733a2f2f706f7365722e707567782e6f72672f73697a7568696b6f2f68657870726573732f646f776e6c6f616473)](https://packagist.org/packages/sizuhiko/hexpress) [![Latest Unstable Version](https://camo.githubusercontent.com/3adadd1d6785861253d90f05bfce6501a8d03f5775edd6f321e5954f876eb148/68747470733a2f2f706f7365722e707567782e6f72672f73697a7568696b6f2f68657870726573732f762f756e737461626c65)](https://packagist.org/packages/sizuhiko/hexpress) [![License](https://camo.githubusercontent.com/778d1371ccadbf0dda46addc6946279b87117149869fe0389b6af0b2191a79c9/68747470733a2f2f706f7365722e707567782e6f72672f73697a7568696b6f2f68657870726573732f6c6963656e7365)](https://packagist.org/packages/sizuhiko/hexpress)

hexpress
========

[](#hexpress)

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

hexpress is ported from Ruby's [hexpress](https://github.com/krainboltgreene/hexpress).

The hexpress is another take at the concept of ["Verbal Hexpressions"](http://verbalexpressions.github.io/).

hexpress requires PHP &gt;= 5.5

Using
-----

[](#using)

```
use Hexpress\Hexpress;

$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();
```

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`:

```
echo $pattern;             #=> "^https?\:\/\/(?:(?:\w)+\.)?([\w\-]+)\.(?:com|org)\/?$"
echo $pattern->toRegExp(); #=> "/^https?\:\/\/(?:(?:\w)+\.)?([\w\-]+)\.(?:com|org)\/?$/"
```

You can even do advanced composure of multiple patterns:

```
$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);

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

Hexpressions are very flexible.

TODO
----

[](#todo)

- PHP Document and API reference
- lookahead assertions
- lookbehind assertions
- back reference
- conditional subpattern
- once-only subpattern
- Internal option setting

Installing
----------

[](#installing)

Add this line to your application's composer.json:

```
    "require": {
        "sizuhiko/hexpress": ">=1.0"
    },
```

And then execute:

```
$ composer install

```

Or install it yourself as:

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

```

Contributing to this Library
----------------------------

[](#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.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~251 days

Total

2

Last Release

3642d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/132000?v=4)[Kenichiro Kishida](/maintainers/sizuhiko)[@sizuhiko](https://github.com/sizuhiko)

---

Top Contributors

[![sizuhiko](https://avatars.githubusercontent.com/u/132000?v=4)](https://github.com/sizuhiko "sizuhiko (52 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sizuhiko-hexpress/health.svg)

```
[![Health](https://phpackages.com/badges/sizuhiko-hexpress/health.svg)](https://phpackages.com/packages/sizuhiko-hexpress)
```

###  Alternatives

[norkunas/youtube-dl-php

youtube-dl / yt-dlp wrapper for php

512323.2k15](/packages/norkunas-youtube-dl-php)[browner12/helpers

generic helpers

289676.6k7](/packages/browner12-helpers)[kop/yii2-scroll-pager

Infinite AJAX scrolling for Yii2 ListView widget

180706.5k10](/packages/kop-yii2-scroll-pager)[tonysm/importmap-laravel

Use ESM with importmap to manage modern JavaScript in Laravel without transpiling or bundling.

148399.8k1](/packages/tonysm-importmap-laravel)[duncan3dc/fork-helper

Simple class to fork processes in PHP and allow multi-threading

73548.0k4](/packages/duncan3dc-fork-helper)[timothyasp/nova-badge-field

A Laravel Nova field.

58548.0k](/packages/timothyasp-nova-badge-field)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
