FormNameUtils { public static String formatFilenameFromFormName(String formName) { if (formName == null) { return null; } String fileName = formName.replaceAll("[^\\p{L}\\p{Digit}]", " "); fileName = fileName.replaceAll("\\p{javaWhitespace}+", " "); return fileName.trim(); } private  FormNameUtils(); static String normalizeFormName(String formName, boolean returnNullIfNothingChanged); static String formatFilenameFromFormName(String formName);  }
@Test public void formatFilenameFromFormNameTest() { assertThat(formatFilenameFromFormName(null), is(nullValue())); assertThat(formatFilenameFromFormName("simple"), is("simple")); assertThat(formatFilenameFromFormName("CamelCase"), is("CamelCase")); assertThat(formatFilenameFromFormName("01234566789"), is("01234566789")); assertThat(formatFilenameFromFormName(" trimWhitespace "), is("trimWhitespace")); assertThat(formatFilenameFromFormName("keep internal spaces"), is("keep internal spaces")); assertThat(formatFilenameFromFormName("other\n\twhitespace"), is("other whitespace")); assertThat(formatFilenameFromFormName("repeated whitespace"), is("repeated whitespace")); assertThat(formatFilenameFromFormName("Turkish İ kept"), is("Turkish İ kept")); assertThat(formatFilenameFromFormName("registered symbol ® stripped"), is("registered symbol stripped")); assertThat(formatFilenameFromFormName("unicode fragment \ud800 stripped"), is("unicode fragment stripped")); }