int (@NotNull String line, int startIdx) { int singleRParen = line.indexOf(')', startIdx); int next = singleRParen; while (next > -1) { if (next >= 1 && Character.isDigit(line.charAt(next - 1))) { return next; } next = line.indexOf(')', next + 1); if (next != -1) { // found a second closing bracket singleRParen = -1; } } return singleRParen; }