### Question:
StringUtils { public static String removeFirstAndLastOccurrence(String input, String str) { if (input == null) { return null; } input = input.trim(); if (input.isEmpty()) { return ""; } int start = 0; int stop = input.length(); if (input.startsWith(str)) { start = 1; } if (input.endsWith(str)) { stop = input.length() - 1; } input = input.substring(start, stop); return input; }  static String removeFirstAndLastOccurrence(String input, String str); static String prependSubstring(String uri, String subStr); static String prependSubstring(String uri, String subStr, boolean checkAlreadyPrepended); static String prependSubstring(String uri, String subStr, boolean checkAlreadyPrepended, boolean shouldTrimWhitespaceFirst); static String removeLastOccurrence(String input, String subStr); static String resolveExpressions(String expression, Map<String, String> properties);  }### Answer:
@Test public void removeFirstAndLastOccurrenceTest() { assertNull(StringUtils.removeFirstAndLastOccurrence(null, "any-string")); String whiteSpace = " "; assertEquals("", StringUtils.removeFirstAndLastOccurrence(whiteSpace, "any-string")); String hasSlashes = " /blah/ "; assertEquals("blah", StringUtils.removeFirstAndLastOccurrence(hasSlashes, "/")); }