Fix zero-width assertions in capture group eval #111
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change makes
RE2.match(CharSequence input, int start, int end, ...)
treatinput
as extending from(0, input.size()]
for thepurpose of zero-width assertions. Previously,
input
was considered toextend from
(start, end]
.This is required when evaluating capturing groups. RE2/J re-matches the
capturing group within a previous successful match, e.g.
During the evaluation of the last statement, RE2/J re-evaluates the
pattern within group(0) (i.e. "hello"). Before this change, RE2/J would
consider the position after 'o' and before 'w' to be both end-of-text
and end-of-line. This would cause zero-width matchers (e.g. $) to
incorrectly match, generating erroneous group matches in some cases.
Fixes #96, see that issue for more
information.