That's right, if I'm wrong, do you want to know the position where the specific text is in the line? If so, you can do it using the following
String text = "0123hello9012hello8901hello7890";
String word = "hello";
Log.d("startOfWordPosition",text.indexOf(word));
Log.d("endOfWordPosition",text.lastIndexOf(word));
As you can see, it will tell you where the word is, but you need to think about a case where a word may appear more than once. If you are sure that the word will occur only once, then the above code is ideal for you. If not, then you have to somehow solve the problem.
source
share