List<TextRange> (String string) { Matcher matcher = pattern.matcher(string); List<TextRange> ranges = new ArrayList<>(); while (matcher.find()) { ranges.add(TextRange.create(matcher.start(), matcher.end())); } return ranges; }