def range_intersect(a, b, extend=0):
    """
    Returns the intersection between two reanges.

    >>> range_intersect((30, 45), (55, 65))
    >>> range_intersect((48, 65), (45, 55))
    [48, 55]
    """
    a_min, a_max = a
    if a_min > a_max:
        a_min, a_max = a_max, a_min
    b_min, b_max = b
    if b_min > b_max:
        b_min, b_max = b_max, b_min

    if a_max + extend < b_min or b_max + extend < a_min:
        return None
    i_min = max(a_min, b_min)
    i_max = min(a_max, b_max)
    if i_min > i_max + extend:
        return None

    return [i_min, i_max]