@staticmethod
def _scan_brackets(expr_str, fromIndex=0):
    """Looks for matching brackets.

        >>> Expression._scan_brackets('abcde')
        (-1, -1)
        >>> Expression._scan_brackets('()')
        (0, 1)
        >>> Expression._scan_brackets('(abc(def))g')
        (0, 9)
        >>> s = '  (abc(dd efy 442))xxg'
        >>> start_pos, end_pos = Expression._scan_brackets(s)
        >>> print(s[start_pos+1:end_pos])
        abc(dd efy 442)
        """
    start_pos = -1
    end_pos = -1
    scan_depth = 0
    for scan_pos in range(fromIndex, len(expr_str)):
        scan_char = expr_str[scan_pos]
        if scan_char == '(':
            if start_pos == -1:
                start_pos = scan_pos
            scan_depth += 1
        elif scan_char == ')':
            scan_depth -= 1
            if scan_depth == 0:
                end_pos = scan_pos
                break
    else:
        if start_pos != -1 or end_pos != -1:
            raise ValueError('expression syntax error (non-matching brackets?)'
                )
    return start_pos, end_pos
