Reputation: 35213
I would like to create a regexp which validates against all english letters + the swedish "åäö (lower and uppercase)". Also, the word can contain 1 or more "-" and can be of any length.
^[a-zA-Z\dåäöÅÄÖ\-*]*$
Is this correct? Can it be improved? If I recall correctly, a-zA-Z
icludes more than just those letters (some characters in the ascii table between a-z and A-Z).
Update: Here are the characters that I'm refering to:
Update 2: I also want to include digits.
Upvotes: 1
Views: 874
Reputation: 336418
Your regex is OK, but why are you including the asterisk (*
)?
[A-Za-z]
only matches ASCII letters, it's [A-z]
that's problematic because there are some special characters between Z
and a
.
So ^[a-zA-Z\dåäöÅÄÖ-]*$
should be OK.
Upvotes: 1