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
Æ æ Å å Ø ø - '
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
Æ æ Å å Ø ø - '
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.
Hi,
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ÆæÅ娸\-\']*