Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET regular expression

Tags:

c#

.net

regex

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:

a-z
A-Z
Æ æ Å å Ø ø - '

like image 505
vert Avatar asked Dec 09 '22 15:12

vert


1 Answers

new Regex("[^a-zA-ZÆæÅåØø'-]")

The [] creates a character class, then ^ specifies negation, so a character matches the class if it's not one of those listed.

like image 103
Matthew Flaschen Avatar answered Dec 31 '22 16:12

Matthew Flaschen