Skip to content

Instantly share code, notes, and snippets.

@emwadde
Last active October 19, 2020 20:46
Show Gist options
  • Save emwadde/f51b65d2d3f464d35a1f60fe4b77e1da to your computer and use it in GitHub Desktop.
Save emwadde/f51b65d2d3f464d35a1f60fe4b77e1da to your computer and use it in GitHub Desktop.
Codes for JS environments (mostly app-script and nodejs)
//can be used as ArrayFunction in google sheets + appscript
function slugify(input) {
if (input.map) { // Test whether input is an array.
return input.map(slugify); // Recurse over array if so.
} else {
let slug = '';
slug = input.toLowerCase();
slug = slug.replace(/[^\w\s-]/g, '');
slug = slug.replace(/\s+/g, '-');
return slug;
}
}
@emwadde
Copy link
Author

emwadde commented May 17, 2020

LOWER(REGEXREPLACE(REGEXREPLACE(TRIM(SUBSTITUTE(A1,"&","n")),"[^a-zA-Z\d\s:]",""),"\s","-"))

Google Sheet Formula version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment