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 your string and iterate over the matches. It would repeat this process as many times as it could in 1 second. The trouble was that it did the same thing even if you had the Replace or Split tab selected. But now the benchmarking will actually do replacement operations when the Replace tab is selected, and it'll do split operations when the Split tab is selected.
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 your string and iterate over the matches. It would repeat this process as many times as it could in 1 second. The trouble was that it did the same thing even if you had the Replace or Split tab selected. But now the benchmarking will actually do replacement operations when the Replace tab is selected, and it'll do split operations when the Split tab is selected.
Comments
Post a Comment