More generic #formatMatch function