Skip to content

Real fluent PHP regex helper, it simplifies writing regular expressions.

License

Notifications You must be signed in to change notification settings

rudashi/fluent-regex

Repository files navigation

Fluent Regex

Codacy Badge codecov GitHub Actions Workflow Status GitHub last commit
GitHub repo size Total Downloads GitHub License


This package provides a simple way to create regular expression in a fluent way.

Fluent Regex is a library in PHP that simplifies the creation and management of regular expressions through the use of fluent syntax. Traditional regular expressions can be difficult to read and understand, especially when they become complex. Fluent Regex solves this problem by allowing you to build regular expressions using a readable and intuitive object-oriented interface.

If you thought that finding a needle in a haystack was impossible, this repository is for you.

Installation

Install the package via Composer

composer require rudashi/fluent-regex

Version Guidance

Version Branch PHP Version Composer Install
v2.x master ^8.2 composer require rudashi/fluent-regex
v1.x 1.x ^8.1 composer require rudashi/fluent-regex:^1.0

Usage

$regex = Rudashi\Regex::build()
    ->startOfLine()
    ->capture(fn (FluentBuilder $fluent) => $fluent->find('http')->or->find('https'))
    ->then('://')
    ->ignoreCase();

$regex->dump();
// /^(http|https)\:\/\//i

$match = Regex::for('https://100commitow.pl/')->find('100commitow')->check();
// True

Documentation

The Fluent Regex documentation is extensive and complete, making getting started with regular expression syntax a breeze.

Changelog

Detailed changes for each release are documented in the CHANGELOG.md.

Credits

License

The MIT License (MIT). Please see License File for more information.