Module lessons (4/4)
Unicode property escapes
\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 theuflag active. - Understand why
\wfails 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
- 1Mental model: semantic categories instead of ASCII codes
- 24 progressive examples step by step
- 3Guided practical exercises
- 4Quick check
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.