简体   繁体   English

带有字母和数字的单词,可以包含破折号和瑞典语字符

[英]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. 同样,该单词可以包含1个或多个“-”,并且可以是任意长度。

^[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). 如果我没记错的话, a-zA-Z不仅包含那些字母(az和AZ之间的ascii表中的某些字符)还包含更多内容。

http://regexr.com?36svf http://regexr.com?36svf

Update: Here are the characters that I'm refering to: 更新:这是我要指的字符:

Update 2: I also want to include digits. 更新2:我也想包含数字。

在此处输入图片说明

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 . [A-Za-z]仅匹配ASCII字母,这是[Az]的问题,因为Za之间有一些特殊字符。

So ^[a-zA-Z\\dåäöÅÄÖ-]*$ should be OK. 因此, ^[a-zA-Z\\dåäöÅÄÖ-]*$应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 多元化瑞典语单词? - Pluralize Swedish Words? Safari 的下载文件名无法打印瑞典语字符 - Downloaded filename for Safari can't print swedish characters 正则表达式帮助,包含不带空格的数字的单词 - Regex help, words that contain numbers without a space c# 正则表达式在输入未知并且可以包含多个单词时删除单个字符和孤立的空格 - c# Regex to remove single characters and orphaned spaces when input is unknown and can contain multiple words 有没有办法找出C#中的字符串是否不包含数字和字符0-9和AZ? - Is there a way I can find out if a string in C# does not contain the numbers & characters 0-9 and A-Z? 拆分多字字符串时,如何在不包含数字的单词之间保留空格? - How can I retain spaces between words that don't contain numbers when splitting a multi-word string? 如何修复我试图匹配1-100个字母,数字,空格,下划线和短划线的C#正则表达式 - How to repair my C# regex that attempts to match 1-100 characters of letters, numbers, spaces, underscores and dashes 搜索包括瑞典字符 html 编码 - Search including swedish characters html-encoded C# HttpClient 在响应中处理瑞典字符 åäö - C# HttpClient handle swedish characters åäö in response 正则表达式替换用短划线包围的一个字母 - Regular Expression to replace one letter surrounded with dashes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM