Created
June 10, 2020 06:02
-
-
Save alimranahmed/31176f51f08f4741cc6b4ad6b637c264 to your computer and use it in GitHub Desktop.
Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isMatched(string $pattern, string $value): bool | |
{ | |
if ($pattern == $value) { | |
return true; | |
} | |
$pattern = preg_quote($pattern, '#'); | |
$pattern = str_replace('\*', '.*', $pattern) . '\z'; | |
return (bool)preg_match('#^' . $pattern . '#', $value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment