Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code to slugify text. Mainly to use in google sheets.
function slugify(value) {
/*
* Convert the the vs in a range of cells into slugs.
*/
slug = '';
slug = value.substring(0, 30).toLowerCase();
slug = slug.replace(/[^\w\s-]/g, '');
slug = slug.replace(/\s+/g, '-');
Logger.log(slug);
return slug;
}
function test() {
Logger.log(slugify("This is a very very very long text.This is a very very very long text.This is a very very very long text.This is a very very very long text."));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment