Extract Title from html link

后端 未结 2 932
傲寒
傲寒 2021-01-28 23:45

I have the following HTML string:

The Link.  

How can I extract title from the HTML s

2条回答
  •  渐次进展
    2021-01-29 00:03

    With a regular expression, the group will contain it ([^"]*):

    title="([^"]*)"
    

    C#

    using System.Text.RegularExpressions;
    static void Main(string[] args)
        {
            string originalString = "The Link.";
            Regex rgx = new Regex("title=\"([^\"]*)\"", RegexOptions.IgnoreCase);
            Match match = rgx.Matches(originalString)[0];
            Console.WriteLine(match.Groups[1]);
            Console.ReadLine();
        }
    

提交回复
热议问题