import re


def json_path_filter(arg):
    """Parse a JSON filter argument."""
    key, sep, value = arg.strip().partition('~')
    if sep == '~':
        return key, re.compile(value)

    key, sep, value = arg.strip().rpartition('=')
    return key, int(value)