`
vtrtbb
  • 浏览: 359961 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

C#用正则实现简单的报表标记

 
阅读更多

string test = "<rpt:tag name=rpt1 col=1 row=2 order=asc>abcsadf </rpt:tag> aaa  <rpt:tag name=rpt2 col=4 row=10 order=desc>abcsadf </rpt:tag>";
MatchCollection mc = Regex.Matches(test, @"<rpt:tag[^>]*>", RegexOptions.IgnoreCase);
int z = 0;
foreach (Match m in mc)
{
    txt.Text += "第" + ++z + "个tag的属性:\n";
    MatchCollection mcList = Regex.Matches(m.Value, @"([^\s=]+)=([^\s>]+)", RegexOptions.IgnoreCase);
    foreach (Match mList in mcList)
    {
        txt2.Text += "属性: " + mList.Groups[1].Value + "  值: " + mList.Groups[2].Value + "\n";
    }
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics