PHPackages                             mmtaheridev/reginephp - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mmtaheridev/reginephp

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mmtaheridev/reginephp
=====================

An expressive PHP library for crafting regular expressions fluently.

v1.0.0(10mo ago)11MITPHPPHP ^8.3

Since Aug 26Pushed 10mo agoCompare

[ Source](https://github.com/mmtaheridev/reginephp)[ Packagist](https://packagist.org/packages/mmtaheridev/reginephp)[ Docs](https://github.com/mmtaheridev/reginephp)[ RSS](/packages/mmtaheridev-reginephp/feed)WikiDiscussions main Synced today

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

Regine
======

[](#regine)

 [![Regine Logo](assets/regine-logo.png)](assets/regine-logo.png)**An Expressive PHP Library for Crafting Regular Expressions fluently.**

[![Latest Version](https://camo.githubusercontent.com/7495cc219a9a1417a8a4935ddcdaf07e05001ca986aea15b647cb30e8ba927d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6d7461686572696465762f726567696e657068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mmtaheridev/reginephp)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/ae32826bdbd149eb63f687a73f873ca9fd409c341ba63e9fd20bd0a7a899a996/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d3738374342352e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![Tests](https://camo.githubusercontent.com/937e105fc83966d970d459cb02a1c3da1ba44f5e9522992176e869fce65b8a52/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/mmtaheridev/reginephp)

---

🚀 The Problem Regine Solves
---------------------------

[](#-the-problem-regine-solves)

Regular expressions are powerful but **notoriously difficult** to read, write, and maintain. A simple email validation can look like this:

```
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
```

**Can you immediately understand what this does?** Probably not. And if you need to modify it in 6 months, good luck!

Regine transforms this cryptic pattern into **readable, fluent PHP code**:

```
use Regine\Regine;

$emailPattern = Regine::make()
    ->startOfString()
    ->anyOf('a-zA-Z0-9._%+-')->oneOrMore()
    ->literal('@')
    ->anyOf('a-zA-Z0-9.-')->oneOrMore()
    ->literal('.')
    ->anyOf('a-zA-Z')->between(2, 4)
    ->endOfString()
    ->compile();
```

**Now it reads like English!** 🎉

🏗️ Architecture: Component-Decorator Pattern
--------------------------------------------

[](#️-architecture-component-decorator-pattern)

Regine uses a clean **Component-Decorator architecture** that separates concerns:

- **🧩 Components**: Actual regex content (literals, character classes, anchors, etc.)
- **🎨 Decorators**: Elements that modify/wrap components (groups, quantifiers, lookarounds)

This design provides:

- ✅ **Clean separation of concerns**
- ✅ **Simplified grouping logic**
- ✅ **Maintainable and extensible codebase**
- ✅ **Intuitive API design**

📦 Installation
--------------

[](#-installation)

Install Regine via Composer:

```
composer require mmtaheridev/reginephp
```

**Requirements:**

- PHP 8.3 or higher
- ext-mbstring (for Unicode support)

🎯 Quick Start
-------------

[](#-quick-start)

### Basic Usage

[](#basic-usage)

```
