0

How to remove non ASCII characters from a string?

Share:

The code snippet below remove the characters from a string that is not inside the range of x20 and x7E ASCII code. The regex below strips non-printable and control characters. But it also keeps the linefeed character \n (x0A) and the carriage return \r (x0D) characters.

Snippet output:

Filed in: Regular Expressions
© 2014 Java Examples - Built with love by Wayan Saryada.