Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/switchcat/range-regex
Utility package for generating a regular expression matching numeric ranges
https://github.com/switchcat/range-regex
php php74 regex regex-pattern regexp regular-expression regular-expressions switchcat-framework
Last synced: 1 day ago
JSON representation
Utility package for generating a regular expression matching numeric ranges
- Host: GitHub
- URL: https://github.com/switchcat/range-regex
- Owner: SwitchCat
- License: mit
- Created: 2020-11-14T01:33:27.000Z (about 4 years ago)
- Default Branch: switchcat
- Last Pushed: 2020-11-16T15:52:18.000Z (about 4 years ago)
- Last Synced: 2024-11-19T00:08:04.516Z (1 day ago)
- Topics: php, php74, regex, regex-pattern, regexp, regular-expression, regular-expressions, switchcat-framework
- Language: HTML
- Homepage: https://switchcat.agency
- Size: 241 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[![Twitter Follow](https://img.shields.io/twitter/follow/SwitchcatA?style=social)](https://twitter.com/SwitchcatA)
[![Issues](https://img.shields.io/github/issues/SwitchCat/range-regex.svg?style=flat-square)](https://github.com/SwitchCat/range-regex/issues)
![GitHub All Releases](https://img.shields.io/github/downloads/SwitchCat/range-regex/total?logo=GitHub)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/73d45acfd5e84452939d50c4d617680f)](https://app.codacy.com/gh/SwitchCat/range-regex?utm_source=github.com&utm_medium=referral&utm_content=SwitchCat/range-regex&utm_campaign=Badge_Grade)
SwitchCat/range-regex
## Table of Contents
* [Getting Started](#getting-started)
* [Prerequisites](#prerequisites)
* [Installation](#installation)
* [Usage](#usage)
* [Contributing](#contributing)
* [License](#license)
* [Contact](#contact)
* [Acknowledgements](#acknowledgements)## Getting Started
To get a local copy up and running follow these simple steps.
### Prerequisites
* PHP7.4+
* ext-mbstring
* [Composer](https://getcomposer.org/)### Installation
Use composer from the root of your project folder to download the library.
```sh
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
```sh
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:
- hansott/range-regex
- micromatch/to-regex-range
- jonschlinkert/to-regex-range## Credits
- Hans Ott
- Felix Eloy