import re


def is_active_string(context, flatpage):
    """
    Returns the string ' active' if the requested url starts with the absolute
    url of the given flatpage. Else returns an empty string.
    """
    request = context.get('request')
    if request and re.match(flatpage.slug + '/', request.path[1:]):
        result = ' active'
    else:
        result = ''
    return result