Code Inspections in RegExp
This topic lists all DataGrip code inspections available in RegExp.
You can toggle specific inspections or change their severity level on the Editor | Inspections page of the Settings/Preferences Ctrl+Alt+S.
Inspection | Description | Default Severity |
---|---|---|
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). | Disabled |
Begin or end anchor in unexpected position | Reports | Warning |
Consecutive spaces | Reports multiple consecutive spaces in a RegExp. Because spaces are not visible by default, it can be hard to see how many spaces are required. The RegExp can be made more clear by replacing the consecutive spaces with a single space and a counted quantifier. | Warning |
Duplicate branch in alternation | Reports duplicate branches in a RegExp alternation. For example | Warning |
Duplicate character in character class | Reports duplicate characters inside a RegExp character class. For example | Warning |
Empty branch in alternation | Reports empty branches in a RegExp alternation. For example: | Warning |
Escaped meta character | Reports the escaped meta characters, e.g. | No highlighting, only fix |
Octal escape | Reports octal escapes, which are easily confused with back references. Use hexadecimal escapes to avoid confusion. | No highlighting, only fix |
Redundant character escape | Reports character escapes that are replaceable with the unescaped character without a change in meaning. Note that inside the square brackets of a character class, many escapes are unnecessary that would be necessary outside of a character class. For example the regex | Warning |
Redundant nested character class | Reports unnecessary nested character classes. For example | Warning |
Single character alternation | Reports single char alternation (e.g. | Warning |