Skip to main content

Optimizing Your Regular Expressions

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.

Comments

Popular posts from this blog

Installer for Desktop version of Regex Hero

As Firefox just dropped support for Silverlight I really needed a solution for Regex Hero. So I created an installer for it. It's still Silverlight, but by using the installer you can install it directly to your computer and never need to open it in a browser. If you visit regexhero.net/tester and don't have a browser that supports Silverlight (IE is the only one left), then you'll see download links for 64-bit and 32-bit versions of the installer. When you install it you'll see a link over on the right hand side that says "Activate Regex Hero". This process connects your desktop version of Regex Hero with your online account. So if you're a licensed user this is how you'll gain access to all of those licensed features. Note: Currently there will be a security warning when you try to run either one of these installers. I'm in the process of obtaining a code signing certificate and will update them as soon as possible. You may be wondering a...

Regex Hero Professional is Now Free

Regex Hero is now completely free!  I've been working on this tool off and on for the past 8 years. I spent a lot of time making it very powerful and easy for developers to create efficient regular expressions. Throughout most of this time it's been a paid product. However, with the added pressure of other free tools out there getting better all the time, I've finally decided to make Regex Hero free as well. Enjoy! Try Regex Hero at http://regexhero.net/tester/

Regex Hero Super Speed, Super Intelligence, and Ultimate

 Last week version 2.0 of Regex Hero landed in the Microsoft Store . What's new in Regex Hero 2.0? You can still use the basic functionality of Regex Hero for free. But there are now 3 paid products within Regex Hero: Super Speed Pack: Benchmarking and regex performance recommendations. Super Intelligence Pack: Local saving and regex explanations. Ultimate: Contains all features of Super Speed and Super Intelligence Packs. I hope you enjoy these new features.