regex – Character class for any letter, including all kinds of accents


I found a regular expression that works for a particular case: an input that can receive all kinds of accents and also hyphens, and prevents any other sign inside the input.

However, I don't really understand why it is defined that way. I do not want to copy and paste something that I do not understand why it works for me. I don't know if it applies to a question, but I ask it anyway.



The regular expression: /^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/ is composed of the following:

/ indica el inicio y fin de la expresión regular
^ inicio del string
$ fin del string   
[xyz] denota un conjunto de caracteres
a-z caracteres entre la a minuscula y la z minuscula charcode 97 al 
A-Z caracteres entre la A mayúscula y la Z mayúsucla charcode 65 al 90
À-Ö charcode 192 al 214
Ø-ö charcode 216 al 246
ø-ÿ charcode 248 al 255
+ una o mas caracteres

that is, the regular expression matches any string that has the characters between the brackets [] and that has a length of 1 or greater.

The regular expression is based on the ascii characters

I also recommend using: or to evaluate your expressions

Scroll to Top