PatternUtils { public static String removeFirstAndLastChars(String expression) { if (expression == null || expression.length() < 2) { return expression; } return expression.substring(1, expression.length() - 1); }  static boolean isExactMatch(String expression); static boolean isContainsMatch(String expression); static boolean isRegex(String expression); static String removeFirstAndLastChars(String expression);  }
@Test public void testRemoveFirstAndLastChars() { assertThat(removeFirstAndLastChars("1234"), equalTo("23")); assertThat(removeFirstAndLastChars("1"), equalTo("1")); assertThat(removeFirstAndLastChars(""), equalTo("")); assertThat(removeFirstAndLastChars(null), is(nullValue())); }