←back to thread

698 points jgrahamc | 1 comments | | HN request time: 0.246s | source
1. Thorrez ◴[] No.20426548[source]
> It might also be obvious that once state 4 was reached (after x= was matched) the regular expression had matched and the algorithm could terminate without considering the final x at all.

That's true if you just want a boolean result. But if you want to get the matched string (which it appears the actual code does), then you need to continue, because it's using greedy matching.