Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string Slug(string s)
- {
- s = s.Normalize(NormalizationForm.FormD);
- StringBuilder sb = new StringBuilder();
- foreach (char c in s) {
- if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark){
- sb.Append(c);
- }
- }
- s = sb.ToString().Normalize(NormalizationForm.FormC);
- s = Regex.Replace(s, "[^a-z0-9_\-]+", "-", RegexOptions.IgnoreCase);
- s = s.Trim(new char[] { "-" });
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment