def METHOD_NAME(d: DocInfo, args: ReplaceArgumentsCLI) -> int:
    """Same as :func:`perform_replace`, but prints the matches according to the provided format."""
    n = 0
    for r in perform_replace(d, args):
        n = r.search_result.num_pars_found
        if r.error:
            print(r.error + ":")
        print(f"{r.format_match(args)}")
    return n