Created
December 19, 2013 03:47
-
-
Save coreyjs/8034124 to your computer and use it in GitHub Desktop.
c# string collection methods, early work
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
public static class StringExtensions | |
{ | |
public static string Truncate(this string value, int maxLength) { | |
if (!string.IsNullOrEmpty(value) && value.Length > maxLength) { | |
return value.Substring(0, maxLength); | |
} | |
return value; | |
} | |
public static string SeoCleanString(this string input) | |
{ | |
if (!string.IsNullOrEmpty(input)) | |
{ | |
input = input.Replace(' ', '-'); | |
return Regex.Replace(input, @"[^A-Za-z0-9\-\s]", ""); | |
} | |
return ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment