def renavactive(request, pattern):
    """
    {% renavactive request "^/a_regex" %}
    """
    if re.search(pattern, request.path):
        return getattr(settings, "NAVHELPER_ACTIVE_CLASS", "active")
    return getattr(settings, "NAVHELPER_NOT_ACTIVE_CLASS", "")
{% renavactive request "^/a_regex" %}