Skip to content

Instantly share code, notes, and snippets.

@iGitScor
Last active April 4, 2018 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iGitScor/5a69b94b8c3f4329cb446c35aa4b9eeb to your computer and use it in GitHub Desktop.
Save iGitScor/5a69b94b8c3f4329cb446c35aa4b9eeb to your computer and use it in GitHub Desktop.
Normalize
"mon string avé des accents".normalize("NFD").replace(/[\u0300-\u036f]/g, ''); // Remove accent
"mon string avé des accents".normalize("NFD").replace(/([^a-zA-Z0-9 ]*)/g, ''); // Keep only letters, numbers and space
"mon string avé des accents".normalize("NFD")
.replace(/[\u0300-\u036f]/g, '')
.replace(/([^a-zA-Z0-9 ]*)/g, '') // Remove accent and then keep letters, numbers and space
"mon string avé des accents".normalize("NFD")
.replace(/[\u0300-\u036f]/g, '')
.replace(/[\/!-,]/g, '') // Remove slash ("/"), interrogation point ("!"), dash ("-"), comma (",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment