I has found this android method TextUtils.regionMatches
But for some reason, so it is not clear how this function works.
The function can be found here: http://developer.android.com/reference/android/text/TextUtils.html#regionMatches%28java.lang.CharSequence,%20int,%20java.lang.CharSequence,%20int,%20int%29
And the base code for this method here, http://androidxref.com/4.1.1/xref/frameworks/base/core/java/android/text/TextUtils.java#220
Thanks for those who might shed some light on how the function is called.