简体   繁体   中英

Words with letter and numbers that can contain dashes and swedish characters

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 az and AZ).

http://regexr.com?36svf

Update: Here are the characters that I'm refering to:

Update 2: I also want to include digits.

在此处输入图片说明

Your regex is OK, but why are you including the asterisk ( * )?

[A-Za-z] only matches ASCII letters, it's [Az] that's problematic because there are some special characters between Z and a .

So ^[a-zA-Z\\dåäöÅÄÖ-]*$ should be OK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM