JetBrains Rider 2019.1 Help

Code Inspections in RegExp

Inspection

Description

Default Severity

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.

New in 2017.1

Warning
Single character alternation

Reports single char alternation ( a|b|c|d ) in a RegExp.It is simpler and significantly faster to use a character class ( [abcd] ) instead.

New in 2017.1

Warning
Octal escape

Reports octal escapes, which are easily confused with back references.Use hexadecimal escapes to avoid confusion.

New in 2017.1

Info
Duplicate branch in alternation

Reports duplicate branches in a RegExp alternation. For example (a|b|a).Duplicate branches slow down matching and obscure the intent of the expression.

New in 2017.1

Warning
Escaped meta character

Reports the escaped meta characters, e.g. \. .Some RegExp coding styles specify that meta characters should be placed inside a character class,to make the regular expression easier to understand.For example the regex \d+\.\d+ would be written as \d+[.]\d+.This inspection does not warn about the meta character [ , ] and ^ ,because those would need additional escaping inside a character class.

New in 2017.1

Info
Empty branch in alternation

Reports empty branches in a RegExp alternation. For example:
a||b

An empty branch will only match the empty string, and in most cases that is not what is desired.This inspection will not report a single empty branch at the start or the end of an alternation.

New in 2017.2

Warning
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).

New in 2017.2

Disabled

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 [\.] is identical to [.]

New in 2017.3

Warning
Begin or end anchor in unexpected position

Reports ^ or \A anchors not at the beginning of the pattern and$, \Z or \z anchors not at the end of the pattern.In the wrong position these RegExp anchors prevent the pattern from matching anything.In case of the ^ and $ anchors, most likely the literal character was meant and the escape forgotten.

New in 2018.1

Warning
Last modified: 11 June 2019