azibom/easy-regex

PHP Regular expressions made easy.

1.0.7 2023-09-17 17:02 UTC

This package is auto-updated.

Last update: 2024-04-28 20:55:10 UTC


README

PHP Regular expressions made easy

codecov example workflow License Latest Stable Version PHP version Build Status

Prerequisites

You need them before installing the package.

  • You need PHP 7.2.5 or above
  • You composer 2.3 or above

Installation

composer require azibom/easy-regex

Usage

<?php

require 'vendor/autoload.php';

use Azibom\EasyRegex\Builder;

$builder = new Builder();
$builder
    ->start()
    ->see("http")
    ->maybeSee("s")
    ->see("://")
    ->something()
    ->see(".")
    ->something()
    ->end();

echo $builder->getRegex() . PHP_EOL; 

if ($builder->match("https://google.com")) {
    echo "Match found!" . PHP_EOL;
} else {
    echo "No match." . PHP_EOL;
}

// /^(http)(s)?(\:\/\/)(?:.+)(\.)(?:.+)$/
// Match found!

Roadmap

The goal of this project is to make a complete regex helper library for the PHP language.

Contribution

Any contribution in the form of an issue or a pull request is more than welcome! Also if you have any questions, feel free to create a new issue or comment on existing ones.