Skip to content

Utility package for generating a regular expression matching numeric ranges

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

SwitchCat/range-regex

Repository files navigation

Twitter Follow Issues GitHub All Releases License: MIT Codacy Badge


SwitchCat/range-regex

Table of Contents

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

Installation

Use composer from the root of your project folder to download the library.

composer require switchcat/range-regex

Usage

All method return an array containing either the element's data either an array of elements with their data.

  • Create the periodic object
use SwitchCat\RangeRegex\FactoryDefault;
use SwitchCat\RangeRegex\Range;

$Factory = new FactoryDefault();
$converter = $Factory->getConverter();
$Range = new Range(int $min, int $max);

$regex = sprintf('/^(%s)$/', $converter->toRegex($Range));
// /^([1-9]|[1-9][0-9]|[1-9][0-9]{2}|[1-2][0-9]{3}|3[0-3][0-9]{2}|34[0-4][0-9]|345[0-6])$/

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Acknowledgements

No major change has been brought to the original package. Basically ported it to php7.4 (fixed compatibility issues) and added a test suite. Some code optimization has been done in order to comply with code inspection standards. The package was marked "abandoned" and i found it very usefull. I simply decided to give it a second life.

Based on the work of:

Credits