lib: refactor match_format() output functions