Skip to content

RegexOptions.NonBacktracking isn't always matching semantics of backtracking engines #65607

Closed

Description

@stephentoub

We recently tried to instill the NonBacktracking engine with the ability to match the semantics of the backtracking engine, in terms of returning the same matches it would under the same circumstances. We've missed some circumstances, though. Here's an example from @olsaarik:

var r = new Regex(".{4}x|ab");
var r2 = new Regex(".{4}x|ab", RegexOptions.NonBacktracking);
Assert.Equal(r.Match("aabax").Value, r2.Match("aabax").Value); // fails

"the problem here is that the first phase stops when it matches on ab, then the reverse second phase extends the match backwards from there, but since there's no x it can't go all the way back to the beginning and then the third phase will start from the wrong point"

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. stephentoub commented on Apr 20, 2022

    @stephentoub
    MemberAuthor

    @olsaarik, this is fixed by #68199 and can be closed, yes?

  5. ghost locked as resolved and limited conversation to collaborators on May 20, 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