2 ms·
Surely the simplest optimisation to add would be anchors? Instead of starting the 'good' line "[12]", start it "^[12]". As it stands, the 'good' regex will loo
by vacri 11y ago
Surely the simplest optimisation to add would be anchors? Instead of starting the 'good' line "[12]", start it "^[12]".
As it stands, the 'good' regex will look through the whole line for any occurrence of 1 or 2 in the line, then start applying the rest of the regex from there. Putting an anchor in means it only looks at the first character for that 1 or 2.