The Java analyzer helps you write less complex regular expressions

Hello Java developers,

We completed our set of rules dedicated to regular expressions by adding 6 rules to help you reduce their complexity for better readability and maintainability.

Here is the list:

  • S6326: Regular expressions should not contain multiple spaces
  • S6396: Superfluous curly brace quantifiers should be avoided
  • S6353: Regular expression quantifiers and character classes should be used concisely
  • S6397: Character classes in regular expressions should not contain only one character
  • S6331: Regular expressions should not contain empty groups
  • S6395: Non-capturing groups without quantifier should not be used

In total, it’s now 30 rules that are there to write clean regular expressions in Java.

They are available now on and will be part of SonarQube 9.5.