Skip to content

Commit

Permalink
fix 通配转正则
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Nov 28, 2024
1 parent 101dda4 commit 1995400
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Traits/BasicMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public static function GetLockKey(string $key): string
*/
public static function WildcardToRegex(string $match): string
{
$regex = str_replace('*', '.+', $match);
$regex = str_replace('?', '.', $regex);
$regex = preg_quote($match, '/'); // 对特殊字符进行转义
$regex = str_replace('\*', '.+', $regex);
$regex = str_replace('\?', '.', $regex);
return '/^' . $regex . '$/';
}

Expand Down

0 comments on commit 1995400

Please sign in to comment.