/fluent-regex

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

Primary LanguagePHPMIT LicenseMIT

Fluent Regex

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


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.

Requirements

  • PHP 8.1+
  • Composer

Installation

Install the package via Composer

composer require rudashi/fluent-regex

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.