源文件是html文件
string s="<a href=\"/Company/Company_detail.asp?id=22652\"><font class=\"d\" color=#aa0000><a href=\"/Company/Company_detail.asp?id=22586\">"类似这样的
我想用正则表达式得到
Company_detail.asp?id=22652
Company_detail.asp?id=22586
如何写
判断的strmiddle="Company_detail.asp?id="是从数据库里读出来的变量
我是这样 可是不行String pattern= "" + strurlmiddle + "[^>]*/";
Regex r=new Regex(pattern,RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection matches=r.Matches(strResult);
Console.WriteLine("Number of groups found = " + matches.Count);
foreach( Match m in matches)
{
string sv = m.Groups[1].Value;
}
string s="<a href=\"/Company/Company_detail.asp?id=22652\"><font class=\"d\" color=#aa0000><a href=\"/Company/Company_detail.asp?id=22586\">"类似这样的
我想用正则表达式得到
Company_detail.asp?id=22652
Company_detail.asp?id=22586
如何写
判断的strmiddle="Company_detail.asp?id="是从数据库里读出来的变量
我是这样 可是不行String pattern= "" + strurlmiddle + "[^>]*/";
Regex r=new Regex(pattern,RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection matches=r.Matches(strResult);
Console.WriteLine("Number of groups found = " + matches.Count);
foreach( Match m in matches)
{
string sv = m.Groups[1].Value;
}
System.Text.RegularExpressions.Regex r =
new System.Text.RegularExpressions.Regex(@"\<a href=[^\>][^\"">](?<objName>[^\>]*)\>",System.Text.RegularExpressions.RegexOptions.IgnoreCase );
System.Text.RegularExpressions.MatchCollection mc;
mc = r.Matches(strText);
for(int i = 0; i < mc.Count; i++)
{
string strValue = mc[i].Groups["objName"].ToString();
}
string strurlmiddle = "Company_detail.asp?id=";String pattern= "" + Regex.Escape(strurlmiddle) + "[^>\"'\\s]*";Regex r=new Regex(pattern,RegexOptions.IgnoreCase | RegexOptions.Compiled);MatchCollection matches=r.Matches(strResult);
Console.WriteLine("Number of groups found = " + matches.Count);
foreach( Match m in matches)
{
string sv = m.Value;
Console.WriteLine(sv);
}