如何用正则表达{C#name=header,ID=1,Content=内容}将name,ID,Content的值取出来

[复制链接]
查看11 | 回复2 | 2012-12-31 16:48:43 | 显示全部楼层 |阅读模式
写个方法吧private string GetSpecifiedValue(string source, string keyName)
{
string regex = string.Format(@"(?:.*{0}=)(?[^,]*)", keyName);
Regex ex = new Regex(regex);
var temp = ex.Match(source);
return temp.Groups[keyName].Value;
}用法 string test =...
回复

使用道具 举报

千问 | 2012-12-31 16:48:43 | 显示全部楼层
直接用name=(.*?),ID=(.*?),Content=(.*?)然后取组1,2,3不就行了...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行