@Test public void testEscapeNonWordCharacters() { Assert.assertEquals( StringEscapeHelper .escapeNonWordCharacters("abcdefghijklmnopqrstuvwxyz-012345.6789ABCDEFGHIJKLMN_OPQRSTUVWXYZ"), "abcdefghijklmnopqrstuvwxyz-012345.6789ABCDEFGHIJKLMN_OPQRSTUVWXYZ"); Assert.assertEquals(StringEscapeHelper.escapeNonWordCharacters("?$ab!\"A;:"), "__ab__A__"); Assert.assertEquals(StringEscapeHelper.escapeNonWordCharacters("({ab[@0*+"), "__ab__0__"); Assert.assertEquals( StringEscapeHelper.escapeNonWordCharacters("^%Q&/P)]T=\\U~#Z'|F<>S`,R "), "__Q__P__T__U__Z__F__S__R_"); Assert.assertEquals(StringEscapeHelper.escapeNonWordCharacters("L\u00f6we"), "L_we"); }
public static String escapeNonWordCharacters(String str) { int length = str.length(); StringBuilder result = new StringBuilder(); for (int i = 0; i < length; i++) { char ch = str.charAt(i); if (ch > 47) { if (ch > 122) { result.append('_'); } else { if (ch > 96 || (ch > 64 && ch < 91) || ch < 58) { result.append(ch); } else { result.append('_'); } } } else if (ch == '.' || ch == '-') { result.append(ch); } else { result.append('_'); } } return result.toString(); }
StringEscapeHelper { public static String escapeNonWordCharacters(String str) { int length = str.length(); StringBuilder result = new StringBuilder(); for (int i = 0; i < length; i++) { char ch = str.charAt(i); if (ch > 47) { if (ch > 122) { result.append('_'); } else { if (ch > 96 || (ch > 64 && ch < 91) || ch < 58) { result.append(ch); } else { result.append('_'); } } } else if (ch == '.' || ch == '-') { result.append(ch); } else { result.append('_'); } } return result.toString(); } }
StringEscapeHelper { public static String escapeNonWordCharacters(String str) { int length = str.length(); StringBuilder result = new StringBuilder(); for (int i = 0; i < length; i++) { char ch = str.charAt(i); if (ch > 47) { if (ch > 122) { result.append('_'); } else { if (ch > 96 || (ch > 64 && ch < 91) || ch < 58) { result.append(ch); } else { result.append('_'); } } } else if (ch == '.' || ch == '-') { result.append(ch); } else { result.append('_'); } } return result.toString(); } private  StringEscapeHelper(); }
StringEscapeHelper { public static String escapeNonWordCharacters(String str) { int length = str.length(); StringBuilder result = new StringBuilder(); for (int i = 0; i < length; i++) { char ch = str.charAt(i); if (ch > 47) { if (ch > 122) { result.append('_'); } else { if (ch > 96 || (ch > 64 && ch < 91) || ch < 58) { result.append(ch); } else { result.append('_'); } } } else if (ch == '.' || ch == '-') { result.append(ch); } else { result.append('_'); } } return result.toString(); } private  StringEscapeHelper(); static String escapeJavaScript(String str); static String escapeJavaScriptInlineHtml(String str); static String escapeJsonInlineHtml(String str); static String escapeNonWordCharacters(String str); static String escapeXml(String buffer); static String getSingleLineTextFromXML(String html); static String removeHtmlMarkup(String str); static String removeXmlMarkup(String str); }
StringEscapeHelper { public static String escapeNonWordCharacters(String str) { int length = str.length(); StringBuilder result = new StringBuilder(); for (int i = 0; i < length; i++) { char ch = str.charAt(i); if (ch > 47) { if (ch > 122) { result.append('_'); } else { if (ch > 96 || (ch > 64 && ch < 91) || ch < 58) { result.append(ch); } else { result.append('_'); } } } else if (ch == '.' || ch == '-') { result.append(ch); } else { result.append('_'); } } return result.toString(); } private  StringEscapeHelper(); static String escapeJavaScript(String str); static String escapeJavaScriptInlineHtml(String str); static String escapeJsonInlineHtml(String str); static String escapeNonWordCharacters(String str); static String escapeXml(String buffer); static String getSingleLineTextFromXML(String html); static String removeHtmlMarkup(String str); static String removeXmlMarkup(String str);  }