regexp/no-octal
💡 This rule is manually fixable by editor suggestions.
disallow octal escape sequence
📖 Rule Details
This rule reports octal escapes.
\0
matches the NUL
character. However, if \0
is followed by another digit, it will become an octal escape sequence (e.g. \07
).
Octal escapes can also easily be confused with backreferences. The same character sequence (e.g. \3
) can either escape a character or be a backreference depending on the number of capturing groups in the pattern. E.g. the \2
in /(a)\2/
is a character but the \2
in /(a)(b)\2/
is a backreference. This can be a problem when refactoring regular expressions because an octal escape can become a backreference or vice versa.
🔧 Options
Nothing.
🚀 Version
This rule was introduced in eslint-plugin-regexp v0.1.0