Last active
October 19, 2020 20:46
-
-
Save emwadde/f51b65d2d3f464d35a1f60fe4b77e1da to your computer and use it in GitHub Desktop.
Codes for JS environments (mostly app-script and nodejs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LOWER(REGEXREPLACE(REGEXREPLACE(TRIM(SUBSTITUTE(A1,"&","n")),"[^a-zA-Z\d\s:]",""),"\s","-"))
Google Sheet Formula version