3 ms·
It would help this example. It wouldn't help the general case.
by rsc 9y ago
It would help this example. It wouldn't help the general case.
- maweki 9y agoBut in general the reversal of a glob pattern is trivial while the reversal of the equivalent regular expression is not, no?
- rsc 9y agoReversing a regular expression and reversing a glob are about the same: you just flip everything around and you're done. In fact RE2 uses this fact to speed up regexp searches. See https://swtch.com/~rsc/regexp/regexp3.html#submatch https://swtch.com/~rsc/regexp/regexp3.html#submatch and scan ahead a bit for "Run the DFA backward".