public static int findText(Text text, Text subtext, int start) {
    // src.position(start) can't accept negative numbers.
    int length = text.getLength() - start;
    if (start < 0 || length < 0 || length < subtext.getLength()) {
      return -1;
    }
    if (subtext.getLength() == 0) {
      return 0;
    }
    if (length == 0) {
      return -1;
    }

    String textString = text.toString();
    String subtextString = subtext.toString();
    int index = textString.indexOf(subtextString, start);
    if (index == -1) {
      return index;
    } else {
      return textString.codePointCount(0, index);
    }
  }
Finds any occurence of <code>subtext</code> from <code>text</code> in the
backing buffer.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFUtils.java