Skip to content

Files

Latest commit

 

History

History
27 lines (17 loc) · 543 Bytes

Lint-MixedRegexpCaptureTypes.md

File metadata and controls

27 lines (17 loc) · 543 Bytes

Pattern: Mixed named and numbered captures

Issue: -

Description

Do not mix named captures and numbered captures in a Regexp literal because numbered capture is ignored if they’re mixed. Replace numbered captures with non-capturing groupings or named captures.

Examples

# bad
/(?<foo>FOO)(BAR)/

# good
/(?<foo>FOO)(?<bar>BAR)/

# good
/(?<foo>FOO)(?:BAR)/

# good
/(FOO)(BAR)/

Further Reading