@Test public void testConvertRegularExpr() { String result = StringUtil.convertRegularExpr("\\t\\r\\n"); Assert.assertEquals(result, "\t\r\n"); result = StringUtil.convertRegularExpr(null); Assert.assertEquals(result, ""); }
public static String convertRegularExpr (String str) { if(str == null){ return ""; } String pattern = "\\\\(\\d{3})"; Pattern r = Pattern.compile(pattern); while(true) { Matcher m = r.matcher(str); if(!m.find()) { break; } String num = m.group(1); int x = Integer.parseInt(num, 8); str = m.replaceFirst(String.valueOf((char)x)); } str = str.replaceAll("\\\\t","\t"); str = str.replaceAll("\\\\r","\r"); str = str.replaceAll("\\\\n","\n"); return str; }
StringUtil { public static String convertRegularExpr (String str) { if(str == null){ return ""; } String pattern = "\\\\(\\d{3})"; Pattern r = Pattern.compile(pattern); while(true) { Matcher m = r.matcher(str); if(!m.find()) { break; } String num = m.group(1); int x = Integer.parseInt(num, 8); str = m.replaceFirst(String.valueOf((char)x)); } str = str.replaceAll("\\\\t","\t"); str = str.replaceAll("\\\\r","\r"); str = str.replaceAll("\\\\n","\n"); return str; } }
StringUtil { public static String convertRegularExpr (String str) { if(str == null){ return ""; } String pattern = "\\\\(\\d{3})"; Pattern r = Pattern.compile(pattern); while(true) { Matcher m = r.matcher(str); if(!m.find()) { break; } String num = m.group(1); int x = Integer.parseInt(num, 8); str = m.replaceFirst(String.valueOf((char)x)); } str = str.replaceAll("\\\\t","\t"); str = str.replaceAll("\\\\r","\r"); str = str.replaceAll("\\\\n","\n"); return str; }  }
StringUtil { public static String convertRegularExpr (String str) { if(str == null){ return ""; } String pattern = "\\\\(\\d{3})"; Pattern r = Pattern.compile(pattern); while(true) { Matcher m = r.matcher(str); if(!m.find()) { break; } String num = m.group(1); int x = Integer.parseInt(num, 8); str = m.replaceFirst(String.valueOf((char)x)); } str = str.replaceAll("\\\\t","\t"); str = str.replaceAll("\\\\r","\r"); str = str.replaceAll("\\\\n","\n"); return str; }  static String convertRegularExpr(String str); static Object string2col(String str, String type, SimpleDateFormat customTimeFormat); static String col2string(Object column, String type); static String row2string(Row row, List<String> columnTypes, String delimiter, List<String> columnNames); static byte[] hexStringToByteArray(String hexString); }
StringUtil { public static String convertRegularExpr (String str) { if(str == null){ return ""; } String pattern = "\\\\(\\d{3})"; Pattern r = Pattern.compile(pattern); while(true) { Matcher m = r.matcher(str); if(!m.find()) { break; } String num = m.group(1); int x = Integer.parseInt(num, 8); str = m.replaceFirst(String.valueOf((char)x)); } str = str.replaceAll("\\\\t","\t"); str = str.replaceAll("\\\\r","\r"); str = str.replaceAll("\\\\n","\n"); return str; }  static String convertRegularExpr(String str); static Object string2col(String str, String type, SimpleDateFormat customTimeFormat); static String col2string(Object column, String type); static String row2string(Row row, List<String> columnTypes, String delimiter, List<String> columnNames); static byte[] hexStringToByteArray(String hexString);  }