List<TextRange> (TextRange target, List<? extends TextRange> deviders) { List<TextRange> result = new ArrayList<>(); result.add(target); for (TextRange devider : deviders) { List<TextRange> temp = new ArrayList<>(); for (TextRange range : result) { if (!range.contains(devider)) { temp.add(range); continue; } if (range.getStartOffset() < devider.getStartOffset()) temp.add(new TextRange(range.getStartOffset(), devider.getStartOffset())); if (range.getEndOffset() > devider.getEndOffset()) temp.add(new TextRange(devider.getEndOffset(), range.getEndOffset())); } result = temp; } return result; }