Regular expressions will backtrack. That's an unfortunate thing about them because backtracking can be slow. And in certain (rare) cases the performance can become so awful that executing the regular expression against a relatively short string could take over a minute. There's a good article about catastrophic backtracking over at regular-expressions.info . And today I created a video about all of this called Regex Lesson 5: Optimization . In the video I start with a very poorly written regular expression and make several improvements to it, using the benchmarking feature along the way. By the end of the video I make the regular expression over 3 million times faster. In addition, today's update to Regex Hero provides a little message in the event that you encounter a regular expression that takes over 10 seconds to evaluate... And then last of all, I changed the benchmarking feature a bit. In the past it would simply test your regular expression against
Comments
Post a Comment