Skip to main content
Module 5 · Lesson 4 of 420/32 in the course~18 min
Module lessons (4/4)

Unicode property escapes

Lesson preview5 hands-on exercises readyRegex Course · Module 5 — Character classes

\p{L}, \p{N}, \p{Script=...} with the u flag: semantic Unicode classes.

What you'll learn in this lesson

  • Use Unicode property escapes (\p{L}, \p{N}, \p{P}, \p{S}, \p{Script=...}) with the u flag active.
  • Understand why \w fails on Italian accented words and non-Latin scripts.
  • Apply the negated form \P{...} (capital P) to filter characters outside a Unicode category.

Overview

The classic shortcuts \w, \d, \s work in a predominantly ASCII perimeter: for \w, words like città, perché or über are broken in half. In modern JavaScript, by activating the u (Unicode) flag, you can use property escapes \p{...} based on the official categories of the Unicode standard.

Instead of guessing intervals like [a-zA-Zàèéìòù...], you ask the engine directly for the Unicode property of the character: "is it a letter of any alphabet?", "is it a currency or mathematical symbol?", "does it belong to the Greek alphabet?".

Sections covered in this lesson

  1. 1Mental model: semantic categories instead of ASCII codes
  2. 24 progressive examples step by step
  3. 3Guided practical exercises
  4. 4Quick check
Pro Lesson · Module 5 — Character classes

Unlock "Unicode property escapes" and the full Regex Course curriculum

`\p{L}`, `\p{N}`, `\p{Script=...}` with the `u` flag: semantic Unicode classes.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Regex Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.