export const stringFormatter = (str: string, espacamento?: boolean, normalize?: boolean): string => { if (typeof str !== 'string') return str; if (!normalize) return str && str.normalize('NFD').replace(/[\u0300-\u036f]/g, '') .replace(/([^\w.,]+|\s+)/g, espacamento ? ' ' : '') // mantém pontos e vírgulas .toUpperCase() || ''; return str && str.normalize('NFD').replace(/[\u0300-\u036f]/g, '') .replace(/[!,",#,$,%,&,',(,),*,+,\\,:,;,<,=,=,>,?,@,[,\],^,_,{,},|,~]/g, espacamento ? ' ' : '') // mantém pontos e vírgulas .toUpperCase() || ''; }