TextRange (String text, int clauseNumber) { int start = 0; while (clauseNumber > 0) { start = text.indexOf(';', start); if (start == -1) return null; start++; clauseNumber--; } int end = text.indexOf(';', start); if (end == -1) { end = text.length(); } if (text.substring(start, end).trim().isEmpty()) return new TextRange(start, end); while (text.charAt(start) == ' ') start++; while (end > start && text.charAt(end - 1) == ' ') end--; return new TextRange(start, end); }