Hacker News new | past | comments | ask | show | jobs | submit login

It's backreference free. Backtracking to process it is just bad design.

Here's a state machine that recognizes /^.*\s+$/:

1: initial state (non-matching)

2: matching state

all states transition to 2 on \s, and to 1 on \S. Done.

Taking this a little further, we can observe that since the transition table is identical for every state, there's no real need to have states at all -- you get the same effect by just checking the last character.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: