Java tutorial
//package com.java2s; public class Main { public static String escapeUnformChar1(String str) { return escapeUnformChar(str, "?"); } public static String escapeUnformChar(String str, String c) { if (str == null || str.length() == 0) return str; return str.replaceAll("[\u0000-\u0008\u000b\u000c\u000e-\u001f]", c); } }