PHPackages                             bassim/super-expressive-php - 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. bassim/super-expressive-php

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

bassim/super-expressive-php
===========================

A PHP port of https://github.com/francisrstokes/super-expressive

v1.0.4(4mo ago)2611.3k7[1 PRs](https://github.com/bassim/super-expressive-php/pulls)MITPHPPHP ^7.4|^8.0CI failing

Since Aug 6Pushed 4mo ago4 watchersCompare

[ Source](https://github.com/bassim/super-expressive-php)[ Packagist](https://packagist.org/packages/bassim/super-expressive-php)[ Docs](https://github.com/bassim/super-expressive-php)[ RSS](/packages/bassim-super-expressive-php/feed)WikiDiscussions master Synced 1mo ago

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/81040d44edf03f56dccfb5467e643b589403c4dcac61addbfa1735ea796f77eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62617373696d2f73757065722d657870726573736976652d7068702e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/super-expressive-php)[![License](https://camo.githubusercontent.com/4ebff0fc015f0af3ad61b12c8d8a80a96ccf6ca08828cf3ff8e7484ba074ee4c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62617373696d2f73757065722d657870726573736976652d7068703f7374796c653d666f722d7468652d6261646765)](https://github.com/super-expressive-php/blob/master/LICENSE.md)[![Postcardware](https://camo.githubusercontent.com/97c40bd733ff9974edecedb00f50f1815339c1fbdaedfdc8930069791979c9ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f737463617264776172652d2546302539462539322538432d3139373539333f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/97c40bd733ff9974edecedb00f50f1815339c1fbdaedfdc8930069791979c9ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f737463617264776172652d2546302539462539322538432d3139373539333f7374796c653d666f722d7468652d6261646765)

[![PHP from Packagist](https://camo.githubusercontent.com/e3a14bf4b5be40dd6f37af18245d06e16b9af16cc550f1da01fb29d6ca3af0ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f62617373696d2f73757065722d657870726573736976652d7068703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/super-expressive-php)[![Build Status](https://camo.githubusercontent.com/e5452e1ae0d8aad044ff5ae09d1b5688287f7a51f09e40cac079897dd204d4b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62617373696d2f73757065722d657870726573736976652d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/bassim/super-expressive-php/actions?query=workflow%3Arun-tests)[![Coverage Status](https://camo.githubusercontent.com/dbe84dd8a7f4db0464c8b9efba07484d3bfc48d6b5baaff65ecc87054de9baac/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f62617373696d2f73757065722d657870726573736976652d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/bassim/super-expressive-php?branch=master)[![Total Downloads](https://camo.githubusercontent.com/0f4fba9d9f7d166b5eee427b676bdd0143e8faebf6e37303be94784bb0c7b590/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62617373696d2f73757065722d657870726573736976652d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/super-expressive-php)

Super Expressive PHP
====================

[](#super-expressive-php)

**Super Expressive PHP** is a PHP library that allows you to build regular expressions in almost natural language - with no extra dependencies, and a lightweight code footprint.

This library is a port of

Why?
----

[](#why)

Regex is a very powerful tool, but its terse and cryptic vocabulary can make constructing and communicating them with others a challenge. Even developers who understand them well can have trouble reading their own back just a few months later! In addition, they can't be easily created and manipulated in a programmatic way - closing off an entire avenue of dynamic text processing.

That's where **Super Expressive PHP** comes in. It provides a programmatic and human readable way to create regular expressions. It's API uses the [fluent builder pattern](https://en.wikipedia.org/wiki/Fluent_interface), and is completely immutable. It's built to be discoverable and predictable:

- properties and methods describe what they do in plain English
- order matters! quantifiers are specified before the thing they change, just like in English (e.g. `SuperExpressive::create()->exactly(5)->digit()`)
- if you make a mistake, you'll know how to fix it. SuperExpressive will guide you towards a fix if your expression is invalid
- [subexpressions](https://github.com/francisrstokes/super-expressive#subexpressionexpr-opts) can be used to create meaningful, reusable components

SuperExpressive turns those complex and unwieldy regexes that appear in code reviews into something that can be read, understood, and **properly reviewed** by your peers - and maintained by anyone!

For the complete API documentation, visit

Example
-------

[](#example)

The following example recognises and captures the value of a 16-bit hexadecimal number like `0xC0D3`.

```
$myRegex = SuperExpressive::create()
  ->startOfInput()
  ->optional()->string('0x')
  ->capture()
    ->exactly(4)->anyOf()
      ->range('A', 'F')
      ->range('a', 'f')
      ->range('0', '9')
    ->end()
  ->end()
  ->endOfInput()
  ->toRegexString();

// Produces the following regular expression:
/^(?:0x)?([A-Fa-f0-9]{4})$/
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require bassim/super-expressive-php
```

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance76

Regular maintenance activity

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 91.8% 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 ~396 days

Recently: every ~494 days

Total

6

Last Release

129d ago

Major Versions

0.0.1 → 1.0.02020-08-09

PHP version history (2 changes)0.0.1PHP ^7.4

v1.0.3PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a94191db919b9d9836339cb775502989a66ea860418dfa51a97308a317e8e757?d=identicon)[Bassim](/maintainers/Bassim)

---

Top Contributors

[![bassim](https://avatars.githubusercontent.com/u/748403?v=4)](https://github.com/bassim "bassim (56 commits)")[![continue[bot]](https://avatars.githubusercontent.com/in/1916892?v=4)](https://github.com/continue[bot] "continue[bot] (4 commits)")[![markhinch](https://avatars.githubusercontent.com/u/512844?v=4)](https://github.com/markhinch "markhinch (1 commits)")

---

Tags

regexregexpbassimsuper-expressive

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bassim-super-expressive-php/health.svg)

```
[![Health](https://phpackages.com/badges/bassim-super-expressive-php/health.svg)](https://phpackages.com/packages/bassim-super-expressive-php)
```

###  Alternatives

[composer/pcre

PCRE wrapping library that offers type-safe preg\_\* replacements.

699313.8M34](/packages/composer-pcre)[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k17.1M59](/packages/spatie-regex)[gherkins/regexpbuilderphp

PHP port of thebinarysearchtree/regexpbuilderjs

1.4k163.0k1](/packages/gherkins-regexpbuilderphp)[regex-guard/regex-guard

A wrapper that allows you to validate regular expressions and handle normally uncatchable PCRE compilation warnings

24509.2k8](/packages/regex-guard-regex-guard)[kozz/emoji-regex

Emoji regex parser

31171.2k](/packages/kozz-emoji-regex)[s9e/regexp-builder

Library that generates regular expressions that match a list of strings.

352.1M4](/packages/s9e-regexp-builder)

PHPackages © 2026

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