You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]".
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.
Issue Details
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 could even build a set of all possible subsequent chars and do a LastIndexOfAny, though the benefits of that appear to be less common.)
stephentoub
changed the title
Regex source generator can use {Last}IndexOf for strings in greedy char loop
Regex compiler/ source generator can use {Last}IndexOf for strings in greedy char loop
Dec 13, 2021
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]".
The text was updated successfully, but these errors were encountered: