| ▲ | masfuerte 5 hours ago | ||||||||||||||||||||||||||||||||||||||||
This is very impressive. > how does RE# find the leftmost-longest match efficiently? remember the bidirectional scanning we mentioned earlier - run the DFA right to left to find all possible match starts, then run a reversed DFA left to right to find the ends. the leftmost start paired with the rightmost end gives you leftmost-longest. two linear DFA scans, no backtracking, no ambiguity. I'm pretty sure that should say "the leftmost start paired with the leftmost end". This also implies that the algorithm has to scan the entire input to find the first match, and the article goes on to confirm this. So the algorithm is a poor choice if you just want the first match in a very long text. But if you want all matches it is very good. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | mananaysiempre 5 hours ago | parent [-] | ||||||||||||||||||||||||||||||||||||||||
> I'm pretty sure that should say "the leftmost start paired with the leftmost end". I’m pretty sure it shouldn’t, that would give you the leftmost shortest match instead of leftmost longest. | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||