文本:<SD>
<POPULARITY URL="pconline.com.cn/" TEXT="298"/>
<REACH RANK="306"/>正则: <POPULARITY[^(/>)]*TEXT=/"(\d+)/"/>
匹配不到298,大家帮帮忙,看问题出在哪里,谢谢
<POPULARITY URL="pconline.com.cn/" TEXT="298"/>
<REACH RANK="306"/>正则: <POPULARITY[^(/>)]*TEXT=/"(\d+)/"/>
匹配不到298,大家帮帮忙,看问题出在哪里,谢谢
解决方案 »
- C# Winform服务器下载文件的诡异问题
- C#窗体传值 AFrom窗体和BForm窗体和Info类
- 如何通过OleDB读取Excell的合并
- 请问Hashtable的一个问题,高手请进
- web盲问两个小web问题
- CheckBox的问题,在线给分
- HttpWebRequest 的问题
- 我用C#做的一个系统 用http://localhost/目录能打开,用http://本机IP/目录能打不开?
- c#写的端口到进程ID的映射,有内存泄露,求大神帮助解决
- 关于跨机器的访问??app-->dll
- 2010下面使用OWC,是否可以实现EXCEL表格的编辑,保存至oracle数据库?
- .NET Frameword 3.5下c#的默认参数(Optional, DefaultParameterValue)的问题
string tempStr = @"<POPULARITY URL=""pconline.com.cn/"" TEXT=""298""/>";
string pattern = @"<POPULARITY[^>]*TEXT=""(?<text>[^""]*)""/>";
MatchCollection mc = Regex.Matches(tempStr, pattern, RegexOptions.Singleline);
for (int i = 0; i < mc.Count; i++)
{
string text = mc[i].Groups["text"].Value;//得到298
this.textBox1.Text += text + "\r\n"; }
string pattern = @"<POPULARITY[^>]*TEXT=""(\d+)\""/>";
string outPut = Regex.Replace(tempStr, pattern,"$1");
outPut就是298你的正则"不对
string tempStr = @"<POPULARITY URL=""pconline.com.cn/"" TEXT=""298""/>";
string pattern = @"<POPULARITY[^>]*TEXT=""(\d+)""/>";
string outPut = Regex.Replace(tempStr, pattern,"$1");应该是这样