当前位置:编程学习 > C#/ASP.NET >>

求教一个正则的小问题

如何获取网页中<tr></tr>之间的数据呢? --------------------编程问答-------------------- http://community.csdn.net/Expert/topic/5696/5696389.xml?temp=.926388 --------------------编程问答-------------------- Regex reg = new Regex("(?<=\<tr\>).*?(?=\</tr\>)");
MatchCollection matches = reg.Matches(inputString);
foreach(Match match in matches)
{
    Console.WriteLine(match.Value);
} --------------------编程问答-------------------- string sourceString = @"<tr><ss>
asdf
</ss></tr>";
string pattern = @"(?<=<tr>)[\s\S]*(?=</tr>)";
给段代码给你:
System.Text.RegularExpressions.Match result = Regex.Match(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase|System.Text.RegularExpressions.RegexOptions.Multiline);

if (result.Success)
{
//提示正确信息
//WL("正确:" + result.Groups[1].Value);//输出
WL("正确:" + result.Value);//输出
} --------------------编程问答-------------------- Match result = Regex.Match(sourceString, @"$(<tr>)(?<content>[\s\S]*)(</tr>)^", RegexOptions.IgnoreCase|RegexOptions.Multiline)

result.Group["content"].Value; // 取出值
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,