okapi / wildcards
PHP Wildcards is a PHP library that converts wildcards to regular expressions.
Installs: 4 043
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-05 18:39:13 UTC
README
PHP Wildcards
PHP Wildcards is a PHP library that converts wildcards to regular expressions.
Installation
composer require okapi/wildcards
Usage
<?php use Okapi\Wildcards\Regex; // Simple wildcard $regex = Regex::fromWildcard('*.php'); $regex->matches('index.php'); // true $regex->matches('index.html'); // false // Wildcard with groups $regex = Regex::fromWildcard('(*.php)|(*.html)'); $regex->matches('index.php'); // true $regex->matches('index.html'); // true $regex->matches('index.js'); // false // Wildcard with optional characters $regex = Regex::fromWildcard('index[*].php'); $regex->matches('index.php'); // true $regex->matches('index.test.php'); // true $regex->matches('index_2.php'); // true
Supported Wildcards
- * = any number of characters
- ? = any single character
- [ ] = optional characters
- ( ) = group
- | = or
Testing
- Run
composer run-script test
or - Run
composer run-script test-coverage
Show your support
Give a ⭐ if this project helped you!
📝 License
Copyright © 2023 Valentin Wotschel.
This project is MIT licensed.