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 关注
- 237 浏览
添加回答
举报
