File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ public function parseGroups(string $regex): ?RegexAstWalkResult
110
110
RegexGroupWalkResult::createEmpty (),
111
111
);
112
112
113
- if (!$ subjectAsGroupResult ->mightContainEmptyStringLiteral ()) {
113
+ if (!$ subjectAsGroupResult ->mightContainEmptyStringLiteral () && ! $ this -> containsEscapeK ( $ ast ) ) {
114
114
// we could handle numeric-string, in case we know the regex is delimited by ^ and $
115
115
if ($ subjectAsGroupResult ->isNonFalsy ()->yes ()) {
116
116
$ astWalkResult = $ astWalkResult ->withSubjectBaseType (
@@ -171,6 +171,21 @@ private function updateCapturingAstAddEmptyToken(TreeNode $ast): void
171
171
$ ast ->setChildren ([$ emptyAlternationAst ]);
172
172
}
173
173
174
+ private function containsEscapeK (TreeNode $ ast ): bool
175
+ {
176
+ if ($ ast ->getId () === 'token ' && $ ast ->getValueToken () === 'match_point_reset ' ) {
177
+ return true ;
178
+ }
179
+
180
+ foreach ($ ast ->getChildren () as $ child ) {
181
+ if ($ this ->containsEscapeK ($ child )) {
182
+ return true ;
183
+ }
184
+ }
185
+
186
+ return false ;
187
+ }
188
+
174
189
private function walkRegexAst (
175
190
TreeNode $ ast ,
176
191
?RegexAlternation $ alternation ,
You can’t perform that action at this time.
0 commit comments