Skip to content

Regex compiler/ source generator can use {Last}IndexOf for strings in greedy char loop #62670

Description

@stephentoub

In greedy char loops, if the loop is followed by a known literal, when backtracking we LastIndexOf to find the next possible place to try to continue the match, rather than just backing up one char at a time. Today we only do this based on a subsequent char literal, but we can extend it to look for a subsequent multi as well. We can also build a set of all possible subsequent chars and do a LastIndexOfAny, e.g. for ".*[abc]".

Activity

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