Skip to content

Instantly share code, notes, and snippets.

@RyanWarner
Created January 23, 2019 16:39
Show Gist options
  • Save RyanWarner/6eef4b461de993f7660e89105ff21027 to your computer and use it in GitHub Desktop.
Save RyanWarner/6eef4b461de993f7660e89105ff21027 to your computer and use it in GitHub Desktop.
// For an array of strings, remove special characters,
// replace spaces with hyphens,
// and convert all characters to lower case.
myArray.map(key => {
const removeSpecials = key.replace(/[^a-zA-Z0-9 -]/, '').replace(/\.|!|'/g, '')
const replaceSpaces = removeSpecials.replace(/ /g, '-')
return replaceSpaces.toLowerCase()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment