[英].NET regular expression
How would I write a regular expression (C#) which will check a given string to see if any of its characters are characters OTHER than the following: 我将如何编写一个正则表达式(C#)来检查给定的字符串,看它是否有任何字符,而不是以下字符:
az
AZ
AZAZ
Æ æ Å å Ø ø - 'ÆæÅåØø - '
new Regex("[^a-zA-ZÆæÅåØø'-]")
[]
创建一个字符类,然后^
指定否定,因此如果一个字符不是列出的那个字符,则该字符与该字符匹配。
You can use character grouping in combination with the negation operator to achieve this. 您可以将字符分组与否定运算符结合使用来实现此目的。
You also need to escape the - character (and potentially the ') using a \\ 你还需要使用\\来转义 - 字符(可能是')
Your final expression would read: 你的最终表达如下:
[^a-zA-ZÆæÅåØø\\-\\']* [^ A-ZA-ZÆæÅåØø\\ - \\'] *
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.