2 回答

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊
由于我的評(píng)論有幫助,我也會(huì)在這里發(fā)布,供其他人查看:
你可以在這里看到這個(gè)
為了方便閱讀:
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main(string[] args)
{
string r =
@"<(?'tag'\w+?).*>" + // match first tag, and name it 'tag'
@"(?'text'.*?)" + // match text content, name it 'textd'
@"</\k'tag'>"; // match last tag, denoted by 'tag'
string text = "<h1>hello</h1>";
Match m = Regex.Match (text, r);
Console.WriteLine (m.Groups ["tag"]); // h1
Console.WriteLine (m.Groups ["text"]); // hello
}
}
- 2 回答
- 0 關(guān)注
- 221 瀏覽
添加回答
舉報(bào)