62,025
社区成员
发帖
与我相关
我的任务
分享
<(.+?)>(?=[\s\S]*?key[\s\S]*?</\1>)
(?<=<(.+?)>[\s\S]*?key[\s\S]*?)</\1>
string keyWord="163";
string para1=string.Format("<[\\s\\S]*?>(?=\\s*{0})",keyWord);
string para2 = string.Format("(?<={0}\\s*)<[\\s\\S]+?>", keyWord);
string content="<div><a href=\"www.163.com\">163<table id=\"sn\"/><href ></div>";
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(para1,System.Text.RegularExpressions.RegexOptions.RightToLeft);
System.Text.RegularExpressions.Regex reg2 = new System.Text.RegularExpressions.Regex(para2, System.Text.RegularExpressions.RegexOptions.Compiled);
MessageBox.Show(reg1.Match(content).Value);//看看是不是楼主想要的值.
MessageBox.Show(reg2.Match(content).Value);