In JavaScript, its easy to match letters and accents with this regex:
text.match(/[a-z\u00E0-\u00FC]+/i);
And only the lowercase letters and accents without the i
option:
text.match(/[a-z\u00E0-\u00FC]+/);
But what is the correct regular expression to match only capitalized letters and accents?
EDIT: like the answers already mention below, the regex above also matches some other signs, and miss some special accent characters like ý and Ý, ć and Ć and many others.
The range U+00C0
- U+00DC
should be the uppercase equivalent for U+00E0
- U+00FC
So this text.match(/[A-Z\u00C0-\u00DC]+/);
should be what you are looking for.
A site like graphemica can help you to determine the ranges you need yourself.
EDIT like the other answers already mention, this also matches some other signs.