"<td>\r\n<a href=\"/xp/a.php?id=134929&name=147&pid=1112\" target=\"_blank\">\r\n<strong class=\"RedWords\">000</strong>\r\n</a>\r\n</td>"麻烦各位我想通过正则拿到该字符串的id也就是134929,随便也写多个正则取
这"/xp/a.php?id=134929&name=147&pid=1112"字符串谢谢,本人对正则不熟.
这"/xp/a.php?id=134929&name=147&pid=1112"字符串谢谢,本人对正则不熟.
汗 貌似写过 忘了
public static IList<string> GetPicPath(string M_Content)
{
IList<string> im = new List<string>();//定义一个泛型字符类
Regex reg = new Regex(@"<a.*?href=""(?<href>[^""]*)""[^>]*>", RegexOptions.IgnoreCase);
MatchCollection mc = reg.Matches(M_Content); //设定要查找的字符串
foreach (Match m in mc)
{
im.Add(m.Groups["href"].Value);
}
return im; }
string M_Content = "<td>\r\n <a href=\"/xp/a.php?id=134929&name=147&pid=1112\" target=\"_blank\">\r\n <strong class=\"RedWords\">000 </strong>\r\n </a>\r\n </td>";
Regex reg = new Regex(@"php\?id=(?<gid>\d+)", RegexOptions.IgnoreCase);
MatchCollection mc = reg.Matches(M_Content); //设定要查找的字符串
foreach (Match m in mc)
{
Response.Write(m.Groups["gid"].Value + "<br/>");
}
Match MV1 = Regex.Match(str, @"\\"(.+?)\\"");
if (MV1.Success )
{
string obj= MV1.Groups[1].Value;
}
obj就是你要的结果,试试看吧