Fix multiline RegEx iteration (breaking change for .Multiline
usage)
#5220
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.
Fixes #5017
Supercedes #5027 by @jist99
In
.Multiline
mode:^
is now defined to assert the start of the string or that a "\n" or "\r" rune was parsed on last VM dispatch.$
is now defined to consume a newline sequence of "\n", "\r", or "\r\n" or to assert the end of the string.This patch is similar to #5027 except that it consumes the newline at the end of a string, not at the start, and this is returned to the user, which should be more sensible. To clarify, every multiline iteration will receive the newline if one is present and only on the final line will the resulting capture have no terminating newline, as this distinction could be relevant to some programs.
I've added a few more tests to define the expected behavior, but I'd like to know if anyone can poke any holes in this.
This change is breaking for any usage of
.Multiline
, as the semantics have changed.