List<TextRange> (String string) { int pos = 0; List<TextRange> ranges = new ArrayList<>(); while (true) { int nextPos = string.indexOf(substring, pos); if (nextPos == -1) break; ranges.add(TextRange.from(nextPos, substring.length())); pos = nextPos + substring.length() + 1; } return ranges; }