Some might argue that this test is unfair to the backtracking implementations, since it focuses on an uncommon corner case. This argument misses the point: given a choice between an implementation with a predictable, consistent, fast running time on all inputs or one that usually runs quickly but can take years of CPU time (or more) on some inputs, the decision should be easy.
Looks as if the answer is really "NFAs (implemented by simulating being in multiple states simultaneously) totally destroy other NFAs (implemented with backtracking)" in speed.
Instead of teaching them in school, it would be better to design a decent UI so that you wouldn't have to "learn" them.State machine diagrams are certainly easier to read and understand then regexps.
wpmu-settings.php, though this is a hacked installation so I don't know if it's originap WPMU code or not). When I realized it was essentially trying to pull domain and subdomain information out of a URL with a dozen calls to strpos and substr, I wondered why they hadn't just used single call to preg_match and maybe two lines of followup code. Maybe they didn't know regexes? No; the ironic flourish is that one of the last things the coder at the end of this sequence did was call preg_replace three times to strip out some information their previous substr and strpos calls missed. « Older "Chris Supranowitz is a researcher at The Ins... | Sure, big numbers are fine. Bu... Newer »
This thread has been archived and is closed to new comments
'Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.'
posted by dammitjim at 5:58 AM on March 17, 2010 [11 favorites]