2 回答

TA貢獻1851條經驗 獲得超5個贊
由于我的評論有幫助,我也會在這里發布,供其他人查看:
你可以在這里看到這個
為了方便閱讀:
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 關注
- 222 瀏覽
添加回答
舉報