androidspannablespannablestringbuilder

How to find index of a substring in a SpannableString


I have a spannable string and I want to find the index of a substring in the spannable string, I don't want to convert it back to a string as the spannable string is already formatted.


Solution

  • TextUtils has many variations of indexOf() to find the index of CharSequence in another CharSequence. Both String and SpannedString are CharSequence implementations.