This post shows you How to Detect URL in text using Regular Expression in C#.

If you want to detect urls contained in a string using c#, you can use this code below.

c# find url from text

static void Main(string[] args)
{
    string txt = "This is my site https://www.foxlearn.com and you can visit my forum at https://c-sharpcode.com";
    if (Regex.IsMatch(txt, @"(http|ftp|https):\/\/([\w\-_]+(??:\.[\w\-_]+)+))([\w\-\.,@?^=%&~\+#]*[\w\-\@?^=%&/~\+#])?"))
    {
        //Do something
    }
}

c# get url from string

string text = "This is my url https://www.foxlearn.com and visit this website and this is my url https://c-sharpcode.com";
List<string> urls = new List<string>();
foreach (var url in Regex.Matches(text, @"(http|ftp|https):\/\/([\w\-_]+(??:\.[\w\-_]+)+))([\w\-\.,@?^=%&amp;~\+#]*[\w\-\@?^=%&amp;/~\+#])?"))
    urls.Add(url.ToString());

Through this c# example, you can learn how to use regular expression in c# to helps you find url from string or get url from string in c#.