pook/api.py
def regex(expression, flags=re.IGNORECASE):
    """
    Convenient shortcut to ``re.compile()`` for fast, easy to use
    regular expression compilation without an extra import statement.

    Arguments:
        expression (str): regular expression value.
        flags (int): optional regular expression flags.
            Defaults to ``re.IGNORECASE``

    Returns:
        expression (str): string based regular expression.

    Raises:
        Exception: in case of regular expression compilation error

    Example::

        (pook
            .get('api.com/foo')
            .header('Content-Type', pook.regex('[a-z]{1,4}')))
    """
    return re.compile(expression, flags=flags)
def regex(expression, flags=re.IGNORECASE):
    """
    Convenient shortcut to ``re.compile()`` for fast, easy to use
    regular expression compilation without an extra import statement.

    Arguments:
        expression (str): regular expression value.
        flags (int): optional regular expression flags.
            Defaults to ``re.IGNORECASE``

    Returns:
        expression (str): string based regular expression.

    Raises:
        Exception: in case of regular expression compilation error

    Example::

        (pook
            .get('api.com/foo')
            .header('Content-Type', pook.regex('[a-z]{1,4}')))
    """
    return re.compile(expression, flags=flags)
Convenient shortcut to ``re.compile()`` for fast, easy to use
    regular expression compilation without an extra import statement.

    Arguments:
        expression (str): regular expression value.
        flags (int): optional regular expression flags.
            Defaults to ``re.IGNORECASE``

    Returns:
        expression (str): string based regular expression.

    Raises:
        Exception: in case of regular expression compilation error

    Example::

        (pook
            .get('api.com/foo')
            .header('Content-Type', pook.regex('[a-z]{1,4}')))