04 Mart 2015

RegEx ve temel komutlar kullanılarak hızlı SEO link oluşturucu

public static string Seo(string text)
{
 if (string.IsNullOrEmpty(text)) return text;

 text = text.ToLower();
 text = text.Replace("&", "ve");
 text = Regex.Replace(text, @"^\s+|\s+$", "", RegexOptions.IgnoreCase | RegexOptions.Multiline);
 text = Regex.Replace(text, @"\s+", "-", RegexOptions.IgnoreCase | RegexOptions.Multiline);
 text = text.Replace("ğ", "g");
 text = text.Replace("ı", "i");
 text = text.Replace("ş", "s");
 text = text.Replace("ç", "c");
 text = text.Replace("ü", "u");
 text = text.Replace("ö", "o");
 text = Regex.Replace(text, @"[^a-z,0-9,-]", "", RegexOptions.IgnoreCase | RegexOptions.Multiline);

 return text;
}

Tagged: ,

0 yorum:

Yorum Gönder