def anchor_pattern(patt):
    """
    anchors a regex in order to force matching against an entire string.
    """
    if not patt.endswith('\\Z'):
        patt = patt + '\\Z'
    if not patt.startswith('\\A'):
        patt = '\\A' + patt
    return patt
