4 ms·
This whole library is troll and people are trolling with it. This: new Matcher().find('Reg').anyWhitespace().capture((expr) => { expr.find('Exp') }).test(
by kbd 8y ago
This whole library is troll and people are trolling with it.
This:
new Matcher().find('Reg').anyWhitespace().capture((expr) => { expr.find('Exp') }).test('Reg Exp')
vs:
'Reg Exp'.match('Reg\s(Exp)')
> Its only redeeming feature is that it's fast (assuming you don't use the wrong features - lookaheads can cripple performance). Looking for alternative abstractions is very worthwhile.
First, it's not particular features of regex that are "slow", but the whole notion of backtracking that's central to how they work! Further, regexes are just a translation of a fundamental mathematical model. In university they even had us translate between finite state machines and regular expressions on tests. In short, any "alternate abstraction" you're looking for is going to be literally the same thing, just wordier, because you're talking about something fundamental in computer science.
In case you're interested, here's a finite state machine to regex translator / simulator linked from the wikipedia page on finite state machines: http://ivanzuzak.info/noam/webapps/fsm_simulator/ http://ivanzuzak.info/noam/webapps/fsm_simulator/
- roblabla 8y agoThat’s literally why I said we shouldn’t trash regexes. It’s not thenidea that sucks. It’s the syntax. The abstraction of the state machine. That’s what sucks. Shorter is not better. Something wordier that’s easier to understand would help alleviate the maintenance burden.