RRegexBuilder
Get RegexBuilder

RegexBuilder · regex answers

Regex to match letters in any language

/^\p{L}+$/u

\p{L} matches any character the Unicode standard classifies as a letter, so Cyrillic, Greek, Arabic and CJK all pass. JavaScript requires the u flag for it; Python needs the third-party regex module, as the standard re does not support \p.

What each part does

\p{L}any Unicode letter
+one or more of them
uthe unicode flag, without which \p is a syntax error in JavaScript

Tested against real input

Every row below was run through the engine when this page was built. The third column is the substring the pattern actually matched.

InputResultMatched
hellomatcheshello
ПриветmatchesПривет
日本語matches日本語
ΕλλάδαmatchesΕλλάδα
hello worldno match
abc123no match
héllo!no match

The mistake to avoid

Reaching for [a-zA-Z] and then filing bug reports about names. Roughly half the world's names contain a character outside that range.

Try it on your own text

Paste this pattern and your input, see each match highlighted with its capture groups, step through what the engine did, and get the equivalent syntax for JavaScript, Python, Java, Go and PCRE.

Open RegexBuilder

Other regex answers