def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar):
    """Find the position just after the matching endchar.

    Args:
      line: a CleansedLines line.
      startpos: start searching at this position.
      depth: nesting level at startpos.
      startchar: expression opening character.
      endchar: expression closing character.

    Returns:
      On finding matching endchar: (index just after matching endchar, 0)
      Otherwise: (-1, new depth at end of this line)
    """
    for i in range(startpos, len(line)):
        if line[i] == startchar:
            depth += 1
        elif line[i] == endchar:
            depth -= 1
            if depth == 0:
                return (i + 1, 0)
    return (-1, depth)