This script for Google Spreadsheets allows you to generate slugs for your data such as might be used for creating unique urls.
Use it like this!
| # | A | B | C |
|---|---|---|---|
| 1 | a | b | slug |
| 2 | foo | baz bing | =slugify(A2:B4) |
| 3 | bar | BAZ | |
| 4 | FOO | baz-bing |
And you get this!
| # | A | B | C |
|---|---|---|---|
| 1 | a | b | slug |
| 2 | foo | baz bing | foo-baz-bing |
| 3 | bar | BAZ | bar-baz |
| 4 | FOO | baz-bing | foo-baz-bing-2 |
Check for a dash surrounded by spaces to eliminate triple dashes:
eg: "Book - Dealer" becomes "book---dealer" instead of "book-dealer"
value = value.replace(/\s-\s/g, ' ');