\ooo is a legacy octal escape: a backslash plus one to three digits from 0–7. It matches the character at that code — for example \101 is A, and \012 is a newline.
Remember
\ooo → character at octal value ooo
\101 → "A" (octal 101 = dec 65)
\141 → "a" (octal 141 = dec 97)
\012 → newline (same as \n)
\011 → tab (same as \t)
digits: 0–7 only
length: 1–3 digits (max \377 = 255)
Write one to three octal digits after \, then test as usual — mainly when reading legacy code.
Convert the character code to octal (digits 0–7 only), up to three digits (max 377).
Put it in a pattern without the u/v flag — e.g. /\101/.
Call test, match, or split on your string.
For new code, rewrite to \xHH, \uXXXX, or a shorthand like \n.
Piece
Required?
Role
\ + digits
Yes
Starts an octal escape (1–3 digits, 0–7)
Max value
—
\377 octal = 255 decimal
Unicode mode
Avoid
/…/u rejects octal escapes
Pseudocode
Pseudocode
pattern contains "\" + ooo // ooo = 1–3 digits, each 0–7
value = parse_octal(ooo) // 0 … 255
target = character(value)
for each char in input:
if char == target:
match this position
else:
try next / fail
Reference
Cheat Sheet
Keep these octal facts handy when reading older patterns.
Topic
Detail
Syntax
\o / \oo / \ooo (digits 0–7)
Letter A
\101 (= \x41)
Letter a
\141 (= \x61)
Newline (LF)
\012 or \n
Tab (HT)
\011 or \t
Convert
parseInt("101", 8) → 65
vs backrefs
\1–\9 usually mean capture groups
Status
Legacy (Annex B) — prefer \xHH
Try it
Live Preview
Pick an octal escape and see what character it matches (and its hex twin).
Browser demo of legacy \ooo — same idea as the examples below.
Result
/\101/.test("ABC")
→ true
/* octal 101 = dec 65 = "A" (= \x41) */
Code
JavaScript Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Match the Letter A with \101
Use an octal escape to test for the character at code 65.
Line feed is octal 12.\012 matches the same character as \n.
Three digits avoid backrefs. Short \1 would look like a capture-group reference.
Tab is octal 11.\011 matches the same character as \t.
Split works the same. Use these when an old pattern lists control codes in octal.
Example 3 — Octal \101 vs Hex \x41
Confirm that octal and hex escapes match the same ASCII letter — then prefer hex for new code.
JavaScript
const ch = "A";
console.log(/\101/.test(ch)); // true (octal)
console.log(/\x41/.test(ch)); // true (hex)
console.log(/\u0041/.test(ch)); // true (Unicode)
// Modern preference for the same character:
console.log(/\x41/.test(ch)); // prefer this in new code
Same character, three notations. Octal 101, hex 41, and Unicode 0041 all mean A.
Octal is legacy. Useful when maintaining old patterns.
Hex is clearer for bytes. Prefer \x41 in new regex.
Unicode for wider range. Use \uXXXX above 255 or when using the u flag.
Edge Cases & Pitfalls
Check these before relying on octal escapes.
backref
\1–\9 are usually backreferences
Short forms clash with capture groups. Prefer three digits (\012) or, better, \x0A / \n.
unicode
Fails with the u / v flag
Unicode mode rejects octal escapes (SyntaxError). Use \xHH or \uXXXX.
digits
Only digits 0–7
8 and 9 are not octal digits. Max value is \377 (255 decimal).
legacy
Prefer \xHH in new code
Octal remains for reading old patterns. New regex should use hex, Unicode, or readable shorthands.
Compatibility
Browser & Runtime Support
Octal escapes in RegExp are legacy JavaScript syntax (ECMAScript Annex B), supported since ES3 in non-Unicode patterns.
✓ Legacy · Annex B
RegExp \ooo
Works in every browser without the u/v flag. Unicode mode rejects octal. Prefer \xHH or \uXXXX for new code.
99%Universal (legacy)
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
\oooExcellent
Bottom line: Safe to read and run in legacy patterns. For new code, migrate to \xHH, \uXXXX, or shorthands like \n — and never combine octal with the u flag.
Analysis
Performance Notes
Approach
Cost
Best for
/\101/
O(n) scan
Reading legacy patterns
/\x41/
O(n) scan
New code (same runtime cost, clearer)
/A/ literal
O(n) scan
Readable ASCII letters
Octal escapes resolve at compile time to a single character — same match cost as \x41 or a literal A. Choose notation for clarity and Unicode-mode compatibility, not speed.
Remember
Key Takeaways
Role: match one character by 1–3 octal digits (0–7), max \377.
Trap:\1–\9 are usually backreferences; u mode forbids octal.
One line: learn \ooo to read legacy regex — write new patterns with \xHH, \uXXXX, or \n/\t.
Frequently Asked Questions
A backslash followed by one to three octal digits (0–7) matches the character with that code point. For example, \101 matches A (octal 101 = decimal 65) and \012 matches a line feed.
One, two, or three octal digits, each from 0 to 7. The value must not exceed 377 octal (255 decimal). Examples: \65, \101, and \011 are all valid.
No. Octal uses digits 0–7 (base 8). Hex \xHH uses 0–9 and A–F (base 16). \101 (octal) equals \x41 (hex)—both match A—but the rules differ. Prefer \xHH in new code.
In a regex pattern, \1 through \9 are usually backreferences to capture groups, not octal. Use three digits (such as \141) or prefer \xHH / \uXXXX to avoid ambiguity.
Generally no. Octal is a legacy form (ECMAScript Annex B). Prefer \xHH for bytes, \uXXXX for Unicode, or shorthands like \n and \t. Learn octal mainly to read older patterns.
No. In Unicode mode (/…/u or /…/v), octal escapes are a SyntaxError. Use \xHH or \uXXXX instead.