composer require okapi/wildcards
<?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
- * = any number of characters
- ? = any single character
- [ ] = optional characters
- ( ) = group
- | = or
- Run
composer run-script test
or - Run
composer run-script test-coverage
Give a ⭐ if this project helped you!
Copyright © 2023 Valentin Wotschel.
This project is MIT licensed.