import re

from django import template

register = template.Library()

@register.filter
def match(value, regex):
    """Usage: {% if value|match:"regex" %}"""
    return re.match(regex, value)