@Test public void substringAfterRemoveQuoteMarks() throws Exception { assertEquals("utf-8", StringUtil.substringAfter("text/html; charset=utf-8", '=', true)); assertEquals("", StringUtil.substringAfter("text/html; charset=", '=', true)); assertEquals("utf-8", StringUtil.substringAfter("text/html; charset=\"utf-8\"", '=', true)); assertEquals("utf-8", StringUtil.substringAfter("text/html; charset='utf-8'", '=', true)); assertNull(StringUtil.substringAfter("text/html", '=', true)); }
public static String substringAfter(String value, char delim, boolean stripQuoteMarks) { if (value == null) { return null; } int startPos = value.indexOf(delim) + 1; int endPos = value.length(); if (startPos == 0) { return null; } if (startPos == endPos) { return ""; } if (stripQuoteMarks && isQuoteMark(value.charAt(startPos))) { startPos++; endPos--; } return value.substring(startPos, endPos); }
StringUtil { public static String substringAfter(String value, char delim, boolean stripQuoteMarks) { if (value == null) { return null; } int startPos = value.indexOf(delim) + 1; int endPos = value.length(); if (startPos == 0) { return null; } if (startPos == endPos) { return ""; } if (stripQuoteMarks && isQuoteMark(value.charAt(startPos))) { startPos++; endPos--; } return value.substring(startPos, endPos); } }
StringUtil { public static String substringAfter(String value, char delim, boolean stripQuoteMarks) { if (value == null) { return null; } int startPos = value.indexOf(delim) + 1; int endPos = value.length(); if (startPos == 0) { return null; } if (startPos == endPos) { return ""; } if (stripQuoteMarks && isQuoteMark(value.charAt(startPos))) { startPos++; endPos--; } return value.substring(startPos, endPos); }  }
StringUtil { public static String substringAfter(String value, char delim, boolean stripQuoteMarks) { if (value == null) { return null; } int startPos = value.indexOf(delim) + 1; int endPos = value.length(); if (startPos == 0) { return null; } if (startPos == endPos) { return ""; } if (stripQuoteMarks && isQuoteMark(value.charAt(startPos))) { startPos++; endPos--; } return value.substring(startPos, endPos); }  static String substringBefore(String value, char delim); static String substringAfter(String value, char delim, boolean stripQuoteMarks); }
StringUtil { public static String substringAfter(String value, char delim, boolean stripQuoteMarks) { if (value == null) { return null; } int startPos = value.indexOf(delim) + 1; int endPos = value.length(); if (startPos == 0) { return null; } if (startPos == endPos) { return ""; } if (stripQuoteMarks && isQuoteMark(value.charAt(startPos))) { startPos++; endPos--; } return value.substring(startPos, endPos); }  static String substringBefore(String value, char delim); static String substringAfter(String value, char delim, boolean stripQuoteMarks);  }