private static CharSequence requireEndUnescaped(CharSequence s){
  int n=s.length();
  int nBackslashes=0;
  while (nBackslashes < n && '\\' == s.charAt(n - nBackslashes - 1)) {
    ++nBackslashes;
  }
  if ((nBackslashes & 1) == 1) {
    return s + "\\";
  }
  return s;
}

private static CharSequence requireEndUnescaped ( CharSequence s ) { int n = s . length ( ) ; int nBackslashes = 0 ; while ( nBackslashes < n && '\\' == s . charAt ( n - nBackslashes - 1 ) ) { ++ nBackslashes ; } if ( ( nBackslashes & 1 ) == 1 ) { return s + "\\" ; } return s ; }
make sure that s does not end with a backslash that would escape any delimiter placed after it .
