-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Finder] Add double-star matching to Glob::toRegex() #21572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you @nicolas-grekas. |
…nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [Finder] Add double-star matching to Glob::toRegex() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Adds ant-style `/**/` matching to `Glob::toRegex()`. Commits ------- 8b28afa [Finder] Add double-star matching to Glob::toRegex()
$firstByte = '/' === $car; | ||
|
||
if ($firstByte && $strictWildcardSlash && isset($glob[$i + 3]) && '**/' === $glob[$i + 1].$glob[$i + 2].$glob[$i + 3]) { | ||
$car = $strictLeadingDot ? '/((?=[^\.])[^/]+/)*' : '/([^/]+/)*'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a possessive quantifier for [^/]++/
to avoid useless backtracking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in #21289
$firstByte = '/' === $car; | ||
|
||
if ($firstByte && $strictWildcardSlash && isset($glob[$i + 3]) && '**/' === $glob[$i + 1].$glob[$i + 2].$glob[$i + 3]) { | ||
$car = $strictLeadingDot ? '/((?=[^\.])[^/]+/)*' : '/([^/]+/)*'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoudln't this use non-capturing groups ?
Adds ant-style
/**/
matching toGlob::toRegex()
.