def METHOD_NAME(
    mode: PatternMode,
    col: str,
    regex: str,
    invert_pattern: bool = False
) -> Filter:
    """Creates a regular-expression pattern filter.
    See https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html for documentation on
    the regex pattern.
    This filter will never match {@code null} values.
    Args:
        mode (PatternMode): the mode
        col (str): the column name
        regex (str): the regex pattern
        invert_pattern (bool): if the pattern matching logic should be inverted
    Returns:
        a new pattern filter
    Raises:
        DHError
    """
    try:
        return Filter(
            j_filter=_JFilterPattern.of(
                _JColumnName.of(col),
                _JPattern.compile(regex),
                mode.value,
                invert_pattern,
            )
        )
    except Exception as e:
        raise DHError(e, "failed to create a pattern filter.") from e