News for hackers. Stuff that matters.
Re:Fast request routing using regular expressions by jules on Thursday February 20, 2014 @08:04AM (#7270520)
You could use a lexer generator instead of regular expressions, since this is exactly what lexer generators do.
Re:Fast request routing using regular expressions by nikic on Thursday February 20, 2014 @09:38AM (#7270916)
You can use a lexer, yes - but any fast lexer implementation in a high-level language will actually use the very same technique described here. Generating a character-comparison + goto based FSM works great in C, but has bad performance in PHP (and other dynamic languages).

There's a common misconception that regular expressions are slow, but in many cases they offer much better performance than a manual implementation with lots of strpos etc. In the end PCRE does the same thing, but in C and using a JIT compiler. Apart from very simple cases you don't have a chance to keep up with that using PHP code.