Created
December 1, 2016 09:31
Code to slugify text. Mainly to use in google sheets.
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
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