Inspectopedia 2024.3 Help

Anonymous capturing group or numeric back reference

Reports anonymous capturing groups and numeric back references in a RegExp. These are only reported when the RegExp dialect supports named group and named group references. Named groups and named back references improve code readability and are recommended to use instead. When a capture is not needed, matching can be more performant and use less memory by using a non-capturing group, i.e. (?:xxx) instead of (xxx).

Example:

(\d\d\d\d)\1

A better regex pattern could look like this:

(?<quad>\d\d\d\d)\k<quad>

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

RegExpAnonymousGroup
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | RegExp

New in 2017.2

Last modified: 03 December 2024