Home JavaScript Regular expressions \uXXXX Definition
What Is \uXXXX? \uXXXX matches one character by its Unicode code unit : the letter u plus exactly four hex digits (0–9, A–F). Example: \u0041 is the letter A.
\u0041 → "A" (U+0041)
\u00A9 → "©" (U+00A9)
\u2665 → "♥" (U+2665)
/\u0041/.test("A") → true
/\u0041/.test("B") → false
/\u00A9/.test("© 2026") → true Use Prefer Match a letter by code /\u0041/ for AMatch a symbol /\u00A9/ for ©Byte-range (0–255) \xHHCode points above FFFF \u{…} with the u flag
Approach
How to Use \uXXXX Look up the code point, write four hex digits, then test or replace.
Find the character’s code (for example U+00A9 for ©). Write \u plus four hex digits: \u00A9. Use it in a pattern: /\u00A9/, or in a string: "\u00A9". Add flags like i or g when case or global replace matters. Piece Required? Role \u + 4 hex digitsYes Identify the code unit to match Hex digits Yes 0–9 and A–F (case-insensitive)Range — U+0000 … U+FFFF (BMP) Flags Optional i, g, and others as needed
Pseudocode pattern has "\u" + fourHexDigits
target = codeUnitFromHex(fourHexDigits) // 0 … 65535
read next character ch from the string
if ch.codeUnit === target:
accept match
else:
fail this path
examples:
\u0041 → match "A"
\u00A9 → match "©"
\u2665 → match "♥" Reference
Cheat Sheet Handy codes and rules for everyday Unicode escapes.
Topic Detail Form \u + exactly 4 hex digitsLetter A \u0041Copyright © \u00A9Heart ♥ \u2665vs \xHH 4 digits (BMP) vs 2 digits (0–255) Emoji / astral \u{1F600} with /uStandard ES3+ (universal)
Try it
Live Preview Run common \uXXXX checks against letters and symbols.
Code
JavaScript Examples Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
1. Letter 2. Symbol 3. vs \xHH Example 1 — Match a Letter by Code Use \u0041 to match the letter A without typing it literally.
console.log(/\u0041/.test("A")); // true
console.log(/\u0041/.test("B")); // false
console.log(/\u0041/.test("Apple")); // true How It Works Four digits. 0041 is the hex code for A.Exact match. "A" matches; "B" is a different code → false.Anywhere in the string. "Apple" starts with A → true.Same as the letter. /\u0041/ and /A/ match the same character.Example 2 — Match Symbols Find copyright and heart symbols by their Unicode values.
console.log(/\u00A9/.test("© 2026")); // true
console.log(/\u2665/.test("I ♥ JS")); // true
console.log(/\u00A9/.test("(c)")); // false How It Works © is U+00A9. \u00A9 matches the real copyright character.♥ is U+2665. The heart in "I ♥ JS" matches.Lookalikes fail. The text "(c)" is not the © symbol.Useful when typing is hard. Escapes keep symbols clear in source code.Example 3 — Compare \u and \x For values 0–255, \u00A9 and \xA9 match the same character.
const text = "©";
console.log(/\u00A9/.test(text)); // true
console.log(/\xA9/.test(text)); // true
console.log("\u00A9" === "\xA9"); // true How It Works Same character. Both escapes resolve to code 169 (©).Different width. \x needs 2 hex digits; \u needs 4.Prefer \u for clarity when discussing Unicode code points.Use \x for bytes when you only care about 0–255 values. Edge Cases & Pitfalls Check these before relying on \uXXXX in real projects.
digits Exactly four hex digits \u41 and \u00441 are invalid. Always pad: \u0041.
emoji Astral characters need braces Code points above U+FFFF (many emoji) need \u{1F600} with the u flag—not a single four-digit \uXXXX.
escape new RegExp needs double escapingWrite new RegExp("\\u0041"). In a string pattern argument you need two backslashes.
case Hex letters are case-insensitive \u00a9 and \u00A9 are the same. The i flag affects letter matching of the character, not the hex digits themselves.
Compatibility
Browser & Runtime Support The \uXXXX Unicode escape is core JavaScript syntax (ES3+ ) and works everywhere JS runs. Braced \u{…} needs the u flag (ES2015+ ).
✓ Baseline · ES3+
RegExp \uXXXX Four-digit Unicode escapes work in every modern and legacy browser, plus all Node.js versions.
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support \uXXXX Excellent
Bottom line: Safe for everyday use. Prefer braced \u{…} with /u when targeting emoji or code points above U+FFFF.
Analysis
Performance Notes Approach Cost Best for /\u0041/.test(str)O(n) Single-character detection str.replace(/\u00A9/g, "(c)")O(n) Normalizing symbols /[\u0041-\u005A]/O(n) Ranges of code units
Escapes compile to ordinary character matches—no special runtime cost. Prefer \xHH only when you intentionally stay in the 0–255 byte range.
Remember
Key Takeaways Form: \u + exactly four hex digits → one BMP character.
Readable codes: \u0041 is A, \u00A9 is ©.
vs \x: four digits (BMP) vs two digits (0–255).
Emoji: use \u{…} with the u flag for code points above FFFF.
One line: \uXXXX matches a character by four hex digits — pad to four, stay in the BMP, and use \u{…}/u for emoji.
Frequently Asked Questions What does \uXXXX match in a JavaScript regular expression? \u followed by exactly four hexadecimal digits matches the Unicode code unit at that value. For example, \u0041 matches A (U+0041) and \u00A9 matches © (U+00A9).
How many hex digits must follow \u? Exactly four. \u0041 is valid; shorter or longer digit runs are syntax errors in both string literals and regex patterns.
What is the difference between \uXXXX and \xHH? \xHH uses two hex digits (0–255). \uXXXX uses four hex digits and covers the Basic Multilingual Plane from U+0000 to U+FFFF—most letters, symbols, and accented characters.
Can \uXXXX match emoji like 😀? Not with a single four-digit escape for code points above U+FFFF. Use the braced form \u{1F600} with the u flag, or a surrogate pair of two \u escapes.
Does the u flag change how \uXXXX works? The four-digit \uXXXX form works with or without the u flag. The u flag additionally enables braced \u{...} for any Unicode code point, including emoji.
Which browsers support \uXXXX in RegExp? The \uXXXX escape is core JavaScript syntax since ES3. It works in every modern browser and Node.js version.
Next: \v vertical tab Learn how the vertical tab metacharacter matches another control character.
\v tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
6 people found this page helpful
Helpful Share Copy link Suggestion