convert,string,to,url,friendly

Mark 7/27/2016 0

this c# code will convert string to url friendly string

C#
 public static string ToUrlName( this string str)
 {
            str = str.RemoveWhitespace();
            Regex rgx = new Regex( "[^a-zA-Z0-9 -]");
            return rgx.Replace(str, "");
 }

 public static string RemoveWhitespace( this string input)
 {
            return new string(input.ToCharArray()
                .Where(c => ! Char.IsWhiteSpace(c))
                .ToArray());
 }
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments