StringUtils { public static String stripNasties(String str) { if (str == null) { return null; } return RE_NASTIES.matcher(str).replaceAll(""); }  static int countWords(String str, boolean all); static String join(String[] array, String delimiter); static String quoteMetacharacters(String str); static String stripNasties(String str);  }
@Test public void testStripNasties() { assertThat(StringUtils.stripNasties("foo"), is(equalTo("foo"))); assertThat(StringUtils.stripNasties("foo bar"), is(equalTo("foo bar"))); assertThat(StringUtils.stripNasties("foo _ bar"), is(equalTo("foo _ bar"))); assertThat(StringUtils.stripNasties("!@#$%^&*(){}:;\"'|\\<>,.?/"), is(equalTo(""))); assertThat(StringUtils.stripNasties(""), is(equalTo(""))); assertThat(StringUtils.stripNasties(null), is(equalTo(null))); }