Verilen URL Bilgisinin Geçerli Olup Olmadığını Kontrol Et - CSharp


Verilen URL bilgisinin geçerli olup olmadığını kontrol etmeye yarayan csharp kodudur.

Kod


public static bool URLGecerliMi(string url)
{
    string pattern = @"/(http|ftp|https)://[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/";
    Regex reg = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);

    return reg.IsMatch(url);
}

Etiketler
csharp