str = new StringBuilder(str).reverse().toString();
substr = new StringBuilder(substr).reverse().toString();
}
// try to reuse compiled pattern if possible
IndexMatcher matcher = (IndexMatcher)context.exectimeObjectAt(MATCHER_INDEX);
if (matcher == null || !matcher.sameState(substr, '\\')) {
context.putExectimeObject(MATCHER_INDEX, matcher = new IndexMatcher(substr));
}
int index = matcher.matchesAt(str, count);
String ret = index < 0 // no match found
? str
: str.substring(0, index);
if (signed) {
ret = new StringBuilder(ret).reverse().toString();