Regex 101 Discussion I4 - remove unprintable characters from a string
Exercise I4 - remove unprintable characters from a string
Given an input string, remove all characters that are not printable.
--------------
Assuming ASCII - or something like ASCII - non-printing characters have ascii values of 31 or lower. You can match them with the following:
[\x01-\x1F]
and then user Regex.Replace() to replace each of those characters with an empty string.