Skip to content

RegexOptions.NonBacktracking needs to handle capture groups when startat == input.Length #65606

Closed

Description

@stephentoub

Regarding this early-exit:

// If we're starting at the end of the input, we don't need to do any work other than
// determine whether an empty match is valid, i.e. whether the pattern is "nullable"
// given the kinds of characters at and just before the end.
if (startat == input.Length)
{
uint prevKind = GetCharKind(input, startat - 1);
uint nextKind = GetCharKind(input, startat);
return _pattern.IsNullableFor(CharKind.Context(prevKind, nextKind)) ?
new SymbolicMatch(startat, 0) :
SymbolicMatch.NoMatch;
}

From #65531 (comment):

Looking at the new comment I realized this optimization should additionally handle the case where there are capture groups and do the same ApplyEffects thing FindEndPositionCapturing is doing. The difference will be visible for some patterns with nullable capture groups that have anchors in them.
Edit: Oh actually any nullable patterns with nullable capture groups.

cc: @olsaarik

Activity

  1. added this to the 7.0.0 milestone on Feb 19, 2022
  2. ghost added
    untriaged
    on Feb 19, 2022
  3. removed
    untriaged
    on Mar 28, 2022
  4. ghost added
    in-pr
    on Apr 19, 2022
  5. ghost removed
    in-pr
    on Apr 19, 2022
  6. ghost locked as resolved and limited conversation to collaborators on May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions