16 ms·
I'd guess it's building the FSA then running it but instead of yes/no, emitting the last matched character when in a failed state. I believe that's a common(?)
by mdaniel 5y ago
I'd guess it's building the FSA then running it but instead of yes/no, emitting the last matched character when in a failed state. I believe that's a common(?) trick for parsers, so it's plausible they do it for regexes
As for why "standard" libraries don't offer it, I'd guess it's a development-time concession that production usage doesn't require; python specifically does ship batteries included with the tooling required to make such a thing, but appears to shop just shy of cooking the actual FSA
>>> re.sre_parse.parse(r'^(([hH]acker)[ ]?([nN]ews|newsletter))$')
[(AT, AT_BEGINNING), (SUBPATTERN, (1, 0, 0, [(SUBPATTERN...