PHPackages                             chevere/regex - 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. chevere/regex

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

chevere/regex
=============

Validated regular expression

1.0.2(1y ago)424.3k↑15.9%4Apache-2.0PHPPHP ^8.1CI passing

Since Nov 30Pushed 9mo agoCompare

[ Source](https://github.com/chevere/regex)[ Packagist](https://packagist.org/packages/chevere/regex)[ Docs](https://chevere.org)[ RSS](/packages/chevere-regex/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (4)

Regex
=====

[](#regex)

[![Chevere](chevere.svg)](chevere.svg)

[![Build](https://camo.githubusercontent.com/0057ce2dc61ee9c7b67ed8d34feb84521b79ac3fe8ea304cb9ed91c23eb75753/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636865766572652f72656765782f746573742e796d6c3f6272616e63683d312e30267374796c653d666c61742d737175617265)](https://github.com/chevere/regex/actions)[![Code size](https://camo.githubusercontent.com/a46cc7f1e9f166ffeacfd3128bf30030b988c86eb5896f082bd09a463a87e5fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636865766572652f72656765783f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/a46cc7f1e9f166ffeacfd3128bf30030b988c86eb5896f082bd09a463a87e5fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636865766572652f72656765783f7374796c653d666c61742d737175617265)[![Apache-2.0](https://camo.githubusercontent.com/29047936026dec7a8eea5c656159335e4e79bf5d7e29a5e9aa18f73ccf589563/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636865766572652f72656765783f7374796c653d666c61742d737175617265)](LICENSE)[![PHPStan](https://camo.githubusercontent.com/6016298b28550819030c76e9327f62501596a31fd76406695bae2f3d2a1f26a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d626c756576696f6c65743f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![Mutation testing badge](https://camo.githubusercontent.com/29a31c8ef7f673f20565c85743bffbe49d0c4461626f69476a7f731d6f146e05/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742d7371756172652675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246636865766572652532467265676578253246312e30)](https://dashboard.stryker-mutator.io/reports/github.com/chevere/regex/1.0)

[![Quality Gate Status](https://camo.githubusercontent.com/caee9bd31cd1b8766ce1a424e5b8a8cc0d9a09d88f5f217c8701710b84baac8c/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7265676578266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=chevere_regex)[![Maintainability Rating](https://camo.githubusercontent.com/3c0b7d5f1c3003333a1a3f744f07ccc802fc4323834b1372e17b3ef5b21c8500/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7265676578266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_regex)[![Reliability Rating](https://camo.githubusercontent.com/e0a67d8a69784af800dbaca51f0568eabce7acdf36ebad62dc2d830fb5d54cc8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7265676578266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_regex)[![Security Rating](https://camo.githubusercontent.com/493c285717e48ecb472b57d2c234e5770a41f4e9c7798191c40ad423c2da4378/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7265676578266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_regex)[![Coverage](https://camo.githubusercontent.com/b3e1e720fa89e2252cc2aca10fa5b31d4f8b210831a979839c6ee11af84be89a/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7265676578266d65747269633d636f766572616765)](https://sonarcloud.io/dashboard?id=chevere_regex)[![Technical Debt](https://camo.githubusercontent.com/4155cf533c25af4f2b1eefa2a1c4d8d1aea1f992139b5fc73ef7855c4f7b4a2f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7265676578266d65747269633d7371616c655f696e646578)](https://sonarcloud.io/dashboard?id=chevere_regex)[![CodeFactor](https://camo.githubusercontent.com/6f0a27a649f533464f1301c287dcf0d5879d25fbb750b7c2fbb69a6293e87abd/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f636865766572652f72656765782f6261646765)](https://www.codefactor.io/repository/github/chevere/regex)

Summary
-------

[](#summary)

Regex enables to work with a validated [regular expression](https://en.wikipedia.org/wiki/Regular_expression).

Installing
----------

[](#installing)

Regex is available through [Packagist](https://packagist.org/packages/chevere/regex) and the repository source is at [chevere/regex](https://github.com/chevere/regex).

```
composer require chevere/regex
```

Creating Regex
--------------

[](#creating-regex)

Create a Regex by passing the regular expression pattern.

```
use Chevere\Regex\Regex;

$regex = new Regex('/^Hello World!$/');
```

Reading pattern
---------------

[](#reading-pattern)

### As-is

[](#as-is)

The `__toString` method is used to access the pattern passed on instance creation.

```
$string = $regex->__toString();
// /^Hello World!$/
```

### Without delimiters

[](#without-delimiters)

The `noDelimiters` method is used to access to the regex pattern without delimiters.

```
$string = $regex->noDelimiters();
// ^Hello World!$
```

### Without delimiters and anchors

[](#without-delimiters-and-anchors)

The `noDelimitersNoAnchors` method is used to access to the regex pattern without delimiters and anchors.

```
$string = $regex->noDelimitersNoAnchors();
// Hello World!
```

Match
-----

[](#match)

The `match` method provides [preg\_match](https://www.php.net/preg-match).

```
$array = $regex->match('Hello World!');
// [Hello World!]
```

Match All
---------

[](#match-all)

The `matchAll` method provides [preg\_match\_all](https://www.php.net/preg-match-all).

```
$regex->matchAll();
// [Hello World!]
```

Assert Match
------------

[](#assert-match)

The `assertMatch` method asserts that the string matches. It throws `Exceptions\NoMatchException` when failing to assert.

```
$regex->assertMatch('Hello World!');
```

Assert Match All
----------------

[](#assert-match-all)

The `assertMatchAll` method asserts that the string matches all. It throws `Exceptions\NoMatchException` when failing to assert.

```
$regex->assertMatchAll('Hello World!');
```

Documentation
-------------

[](#documentation)

Documentation is available at [chevere.org](https://chevere.org/packages/regex).

License
-------

[](#license)

Copyright 2024 [Rodolfo Berrios A.](https://rodolfoberrios.com/)

Chevere is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance49

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

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

Total

4

Last Release

281d ago

### Community

Maintainers

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

---

Top Contributors

[![rodber](https://avatars.githubusercontent.com/u/20590102?v=4)](https://github.com/rodber "rodber (19 commits)")

---

Tags

cheverephpphp-library

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chevere-regex/health.svg)

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

###  Alternatives

[label84/laravel-hours-helper

Creates a Collection of times with a given interval.

27591.2k](/packages/label84-laravel-hours-helper)[chevere/throwable-handler

Throwable handler for multiple contexts

1131.9k9](/packages/chevere-throwable-handler)[chevere/parameter

Dynamic parameter-argument validation for PHP with rich type constraints, attributes, and schema introspection.

1023.7k20](/packages/chevere-parameter)

PHPackages © 2026

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