I guess I need to buff up on my automata, but I would have thought that for positional delimiters, there would be optimizations. If the pattern is \s+$, then I can look from the back of the line, see if there is a space, and if so, go backward until I find a non-space character.
The trick is that there's no guarantee, in general, that a match failing at character N is due to character N, so the regex engine backtracks.