Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
Created January 2, 2012 10:48
Show Gist options
  • Select an option

  • Save jakebellacera/1550263 to your computer and use it in GitHub Desktop.

Select an option

Save jakebellacera/1550263 to your computer and use it in GitHub Desktop.
Parameterizes a string
function parameterize(value) {
// A simple function that parameterizes a string.
// Example: "This is a title" == "this-is-a-title"
if (typeof value === 'string' || value) {
var output = value.replace(/[^a-zA-Z0-9\s]/g,"");
output = output.toLowerCase();
return output.replace(/\s/g,'-');
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment