R

TestRegex

← Back to Blog

Modern Regex: Unicode Property Escapes

The internet is global. Assuming names only contain ASCII characters (A-Z) is a common mistake that alienates users with names like "José", "Zoë", or "日本語".

The Wrong Way

[a-zA-Z]+ fails on any accented character.

The Modern Way: \p{L}

Unicode Property Escapes allow you to match characters by their Unicode category. \p{L} matches any letter in any language.

// JavaScript (requires 'u' flag)
const regex = /^\p{L}+$/u;
regex.test("München"); // true

This is robust, future-proof, and respectful of your global userbase.