import re


def find_repeats(sequence, pattern):
    """Find repeat pattern in sequence.

    Function that finds repeats sequences using regular expressions and
    and the input pattern.

    Parameters
    ----------
    sequence : String
        DNA sequence string.
    pattern : String
        String used to search the sequence.

    Returns
    -------
    repeat_list : List
        List containing matches for the pattern sequence, each match
        corresponds to a tuple containing the sequence start, end and
        number of repeats.

    """

    # List containing repeats
    repeat_list = []

    # Find repeats ussing regular expressions and pattern
    hit_list = re.finditer(pattern, sequence)

    for repeat in hit_list:

        rep_start, rep_end = repeat.span()

        rep_num = (rep_end - rep_start)/2

        repeat_list.append((rep_start+1, rep_end, rep_num))

    return repeat_list