string.ts 368 B

123456789101112131415161718
  1. /**
  2. * Remove any special characters from the string
  3. *
  4. * @param s
  5. */
  6. function normalize(s: string): string {
  7. return s
  8. .toLowerCase()
  9. .replace(/[éèẽëê]/g, 'e')
  10. .replace(/[ç]/g, 'c')
  11. .replace(/[îïĩ]/g, 'i')
  12. .replace(/[àã]/g, 'a')
  13. .replace(/[öôõ]/g, 'o')
  14. .replace(/[ûüũ]/g, 'u')
  15. .replace(/[-]/g, ' ')
  16. .trim()
  17. }