Regex to match unprintable characters
If you want to get unprintable characters you can use the following simple code:
Expression:
/[^\p{Print}]/
You can see how it works on the following Ruby example:
Code:
omg = "OMG!\nHi! \n\r\t"
omg.gsub(/[^\p{Print}]/, "*")
The result is going to be like that:
"OMG!*Hi! ***"
Written by Steimntz Machado de Figueiredo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Regex
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#