Skip to content

Instantly share code, notes, and snippets.

@jittuu
Created June 26, 2011 06:28
Show Gist options
  • Select an option

  • Save jittuu/1047314 to your computer and use it in GitHub Desktop.

Select an option

Save jittuu/1047314 to your computer and use it in GitHub Desktop.
public static string ToSlug(this string target)
{
var pattern = @"[^0-9a-zA-Z]+";
return Regex.Replace(target, pattern, "-")
.Trim('-')
.ToLowerInvariant();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment