PHPackages                             braincrafted/expexp - 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. braincrafted/expexp

ActiveLibrary

braincrafted/expexp
===================

v0.2.2(12y ago)5201MITPHP

Since Oct 16Pushed 12y ago1 watchersCompare

[ Source](https://github.com/braincrafted/expexp)[ Packagist](https://packagist.org/packages/braincrafted/expexp)[ RSS](/packages/braincrafted-expexp/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

ExpExp
======

[](#expexp)

ExpExp expands expressions. That's kinda the opposite of what regular expressions do.

For example `ab(cd|[xy])` expands to

- `abcd`,
- `abx` and
- `aby`.

[![Build Status](https://camo.githubusercontent.com/62ebb755616eac06fe3d5e4ce014de6ce86faa873352e2482b12149303e7d5f1/68747470733a2f2f7472617669732d63692e6f72672f627261696e637261667465642f6578706578702e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/braincrafted/expexp)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/13cd6cad794c9634f89e42c952eefcbac5e54d662283f3d0fb544eba769698e2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627261696e637261667465642f6578706578702f6261646765732f7175616c6974792d73636f72652e706e673f733d35613334613261393531353732663062316335656562663538303363373536633664313566633332)](https://scrutinizer-ci.com/g/braincrafted/expexp/)[![Code Coverage](https://camo.githubusercontent.com/361cd7e4276d92f61c3b415a9c9689214e970f40f50cd218ef0a2cb4045f003d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627261696e637261667465642f6578706578702f6261646765732f636f7665726167652e706e673f733d37623163313031323634303461376636653863383136656462323339653839633832656639633861)](https://scrutinizer-ci.com/g/braincrafted/expexp/)

Author
------

[](#author)

- [Florian Eckerstorfer](http://florian.ec) ([Twitter](http://twitter.com/Florian_), [App.net](http://app.net/florian))

Features
--------

[](#features)

The following expressions can be expanded by the library:

**Disjunction:**

```
abc[xyz]

```

will be expanded to

- `abcx`
- `abcy`
- `abcz`

**Named character classes:**

Instead of listing all disjunct characters, you can also select from a set of available character classes:

- `upper` contains uppercase characters (from ASCII)
- `lower` contains lowercase characters (from ASCII)
- `digit` contains digits
- `space` contains space characters
- `punct` contains punctuation characters

You can use named character classes by wrapping them in colons:

```
[:upper:]

```

**Dot Operator:**

```
abc.

```

will be expanded to

- `abcA`
- `abcB`
- …

The Dot opterator does not expand to every character, but only to `A-Za-z0-9_`.

**Parantheses:**

```
ab(c)

```

will be expanded to

- `abc`

**Repetition:**

The repetition operator allows to repeat the previous character(s). If only one value is given the previous character is repeated that often, if two values are given the character is multiplied with each value in the given range. `{,3}` is the same as `{0,3}`.

```
a{3}

```

will expand to

- `aaa`

Or with a minimum and a maximum value:

```
a{1,3}

```

will expand to

- `a`
- `aa`
- `aaa`

This also works with disjunctions and parentheses.

**Alternation:**

```
abc|xyz

```

will be expanded to

- `abc`
- `xyz`

**Optional:**

```
abc?

```

will be expanded to

- `abc`
- `ab`

This also works with parantheses:

```
abc(xyz)?

```

will be expanded to

- `abc`
- `abcxyz`

The optional operator has thus the same effect as `{0,1}`.

More examples
-------------

[](#more-examples)

   Pattern Count Expansion     `abc` 1 `abc`   `ab(c)` 1 `abc`   `[abc]` 3 `a`, `b`, `c`   `a{3}` 1 `aaa`   `a{}` 1 `a`   `a{1,3}` 3 `a`, `aa`, `aaa`   `a{,3}` 4 ``, `a`, `aa`, `aaa`   `a(bc){2}` 1 `abcbc`   `a(bc){1,2}` 2 `abcbc`, `abc`   `a(bc){,2}` 3 `a`, `abc`, `abcbc`   `[ab]{2}` 2 `aa`, `bb`   `ab.` 63 `abA`, `abB`, `aba`, `ab0`, `ab_`, ...   `abc|xyz` 2 `abc`, `xyz`   `a|b|c` 3 `a`, `b`, `c`   `ab(c|d)` 2 `abc`, `abd`   `ab(cde|[xyz])` 4 `abcde`, `abx`, `aby`, `abz`   `abc?` 2 `abc`, `ab`   `abc(xyz)?` 2 `abc`, `abcxyz`  Usage
-----

[](#usage)

Instantiate the object and call the `expand()` method with the pattern:

```
use Bc\ExpExp\ExpExp;

$e = new ExpExp();
$result = $e->expand('abc|xyz');

```

More examples can be found in the test cases.

Changelog
---------

[](#changelog)

### Version 0.2.2 (2013-10-20)

[](#version-022-2013-10-20)

- Dot operator matches `word` character class

### Version 0.2.1 (2013-10-19)

[](#version-021-2013-10-19)

- Named character classes

### Version 0.2 (2013-10-19)

[](#version-02-2013-10-19)

- Changed namespace to `Braincrafted`
- Added repetition operator `{}`
- Completely rewritten to be easier and better extensible
- Improved test suite

### Version 0.1.1 (2013-10-16)

[](#version-011-2013-10-16)

- Better code style
- Better in-code documentation

### Version 0.1 (2013-10-16)

[](#version-01-2013-10-16)

- Moved to `Bc` namespace
- Call `expand()` with pattern
- Better documentation

License
-------

[](#license)

ExpExp is licensed under The MIT License. See the `LICENSE` file in the projects root directory for more information.

[![Bitdeli Badge](https://camo.githubusercontent.com/bc00b2fad5c8d6e12bdd39193a1b147748f8c91e6fb30c7756e85855688efcc5/68747470733a2f2f64327765637a68766c38323376302e636c6f756466726f6e742e6e65742f627261696e637261667465642f6578706578702f7472656e642e706e67)](https://bitdeli.com/free "Bitdeli Badge")

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

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 ~1 days

Total

6

Last Release

4589d ago

### Community

Maintainers

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

---

Top Contributors

[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/braincrafted-expexp/health.svg)

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

PHPackages © 2026

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