.Net Regex that matches strings with any non-ASCII char in it

You are looking for black magic that will match any string with "strange" characters. Standard ASCII characters are fine. Everything else is not.

This is for disinfecting various web forms.

+5
source share
2 answers

This gets anything from the ASCII range.

[^\x00-\x7F]

There are some more "weird" characters, such as x00(NULL), but they are valid ASCII.
See ASCII Table for reference.

+6
source

[^\p{IsBasicLatin}] , , [^\x00-\x7F] \p{C} -ASCII ( ).

+2

All Articles