Regular Expression Pitfalls, Optimization, and Performance Improvements

Regular expressions, if not written well may perform poorly. They may run slowly, and when they are executed frequently in some code, they may be the source of high CPU utilization. To avoid these problems, regular expressions have to be crafted carefully, understanding the possible pitfalls, and they also have to be tested thoroughly. We will be covering the following topics in this chapter:

  • Common pitfalls and ways to avoid them while writing regular expressions
  • How to test your regex functionality and performance
  • Optimization and performance enhancing tips
  • Catastrophic backtracking and how to avoid it

Get Java 9 Regular Expressions now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.