A unified treatment for the fermion mass matrices is performed within the theoretical framework of some extensions the standard model (SM), such as SM+S(3) symmetry and 2HDM. In this treatment the mass matrices are represented with a two-zero texture matrix, obtaining exact and explicit expressions for the CKM and leptonic mixing matrices. This way, performing a chi square fit, it is shown that the current experimental data on quarks and leptons masses and mixings can be reproduced. Furthermore, the mass matrices are classified in terms of equivalence classes.