🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / name string to url regex

1-) C# RMOS - name string to url regex

 

public string replaceTurkishKarakter(string text)

        {

            text = text.Replace("Ş", "S");

            text = text.Replace("ş", "s");

            text = text.Replace("İ", "I");

            text = text.Replace("ı", "i");

            text = text.Replace("Ğ", "G");

            text = text.Replace("ğ", "g");

            text = text.Replace("Ç", "C");

            text = text.Replace("ç", "c");

            text = text.Replace("Ö", "O");

            text = text.Replace("ö", "o");

            text = text.Replace("Ü", "U");

            text = text.Replace("ü", "u");

            return text;

        }

 

 public string getUrl(string ad)

        {

            ad = replaceTurkishKarakter(ad.ToLower());

            ad = Regex.Replace(ad, @"[^a-zA-Z0-9\s<]", string.Empty);

            ad = ad.Replace(" ", "-").Replace("#", "").Replace(".", "").ToLower();

            ad = ad.Replace("(", "").Replace(")", "").Trim();

            return ad;

        }

 

 

input : N&D Prime Kuzu Etli Yetişkin Kedi Maması 1.5 Kg

output : nd-prime-kuzu-etli-yetikin-kedi-mamas-15-kg5-kg

 

 

 

example : https://www.petibom.com/nd-prime-kuzu-etli-yetiskin-kedi-mamasi-15-kg5-kg

 

 

 

DİĞER

 

public string replaceTurkish(string text)

        {

            var json = @"{""name"":"""+ text + @"""}";

            var name = JObject.Parse(json)["name"].ToString();

            return name.ToString();

        }

 

KULLANIMI

 

var name = replaceTurkish("Hills Young Sterilised Tavuklu K\u0131s\u0131rla\u015ft\u0131r\u0131lm\u0131\u015f Kedi Mamas\u0131 1.5 Kg")

 

 2022 Mayıs 10 Salı
 392