### Question:
EscapeFunnyCharacters { public static String escapeFunnyCharacters(String vreId) { StringBuffer resultString = new StringBuffer(); Pattern regex = Pattern.compile("[^a-zA-Z0-9_-]"); Matcher regexMatcher = regex.matcher(vreId.replaceAll("_", "__")); while (regexMatcher.find()) { String cur = regexMatcher.group(); if (cur.length() > 1) { throw new RuntimeException("The world is not as I expected it to be!"); } regexMatcher.appendReplacement(resultString, "_" + cur.codePointAt(0) + ""); } regexMatcher.appendTail(resultString); return resultString.toString(); }  static String escapeFunnyCharacters(String vreId);  }### Answer:
@Test public void escapeFunnyCharactersWorks() throws Exception { assertThat(escapeFunnyCharacters("A B"), is("A_32B")); assertThat(escapeFunnyCharacters("A B_/"), is("A_32B___47")); }