如何在C#上获取字符串的中心部分

use*_*116 1 .net c#

我只需要使用C#,就需要Rocky44的中心字符串

Hi <a href="http://example.com/index.php?action=profile"><span>Rocky44</span></a>
Run Code Online (Sandbox Code Playgroud)

我尝试了一些拆分方法,但无法工作

string[] result = temp.Split(new string[] { "<a href=" + "http://example.com/index.php?action=profile" + "><span>" , "</span></a>" }, StringSplitOptions.RemoveEmptyEntries); 
Run Code Online (Sandbox Code Playgroud)

例:

Hi <a href="http://example.com/index.php?action=profile"><span>Rocky44</span></a>
Run Code Online (Sandbox Code Playgroud)

至:

Rocky44
Run Code Online (Sandbox Code Playgroud)

I4V*_*I4V 9

使用html解析器.我将使用HtmlAgilityPack给出一个例子

string html = @"Hi <a href=""http://example.com/index.php?action=profile""><span>Rocky44</span></a>";
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var text = doc.DocumentNode.SelectSingleNode("//span").InnerText;
Run Code Online (Sandbox Code Playgroud)