Numbersflags: g
Octal Number Literal
Match modern ECMAScript-style octal literals (`0o755`) — strict per ES6+ syntax.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\b0[oO][0-7]+\b (flags: g)Raw source: \b0[oO][0-7]+\b
How it works
\b is a word boundary. 0[oO] requires the modern ES6 octal prefix (case-insensitive on the o). [0-7]+ matches one or more octal digits (0–7). \b prevents matching into adjacent letters. Note: the loose `0755` form (no o) is technically a legacy octal in some languages but is dangerous in JS strict mode — this pattern requires the explicit `0o` prefix.
Examples
Input
perms = 0o755; mask = 0o022Matches
0o7550o022
Input
fileMode := 0o644Matches
0o644
Input
no octalNo match
—Common use cases
- •Source-code analysis for file-mode literals
- •Unix permission detection in IaC code
- •Linting against deprecated octal forms
- •Educational / tutorial parsing
Related patterns
Binary Number Literal
NumbersMatch binary number literals like `0b1010` or `0B11110000`.
Hexadecimal Number Literal
NumbersMatch hexadecimal number literals like `0xFF`, `0x1A2B`, or `0XdeadBeef`.
Decimal Number
NumbersMatches decimal numbers, including integers and negatives.
Float / Scientific Number
NumbersMatch floating-point and scientific-notation numbers including `1.5`, `.25`, `1e10`, `-3.14E-2`.