def rep2pwr(string, pattern, delimiter, latex=True, pwrfun=None):
    """
    Given a string with repeated symbols, convert the repetitions to power notation.

    Example:

    >> a = '*x*x*x'
    >> enpower(a,'*x')

        x^{3}

    """
    pwrfun = (lambda pattern, N: '{%s}^{%i}' % (pattern, N)
        ) if pwrfun is None else pwrfun
    maxdeg = len(string.split(pattern))
    ans = str(string)
    for deg in range(maxdeg, 1, -1):
        reppat = delimiter.join([pattern for k in range(deg)])
        ans = ans.replace(reppat, pwrfun(pattern, deg))
    return ans
