求一个正则表达式 <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe" target="_blank">下载此更新其中211a9c07-88ff-4ae4-a82a-ce2045c6c4fe可变,就求这个表达式立即结贴 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string yourStr = ......;MatchCollection mc = Regex.Matches(yourStr, "<a\\s+href=\".+?&FamilyID=(.+?)\".+?>", RegexOptions.IgnoreCase);foreach(Match m in mc){ m.Groups[1].Value;//} using System;using System.Runtime.InteropServices;using System.Text.RegularExpressions;namespace RegexTest{ public class RegexTest { public void Test() { string input = @"<a href=""http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe"" target=""_blank"">下载此更新"; string pattern = @"(?<=&FamilyID=)[a-zA-Z0-9-]{36}(?=" target=)"; RegexOptions options = RegexOptions.None; Regex regex = new Regex(pattern, options); MatchCollection matches = regex.Matches(input); foreach (Match match in matches) { Console.WriteLine(match.Value); } } }} using System;using System.Runtime.InteropServices;using System.Text.RegularExpressions;namespace RegexTest{ public class RegexTest { public static void Main() { string input = @"<a href=""http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe"" target=""_blank"">下载此更新"; string pattern = @"(?<=&FamilyID=)[a-zA-Z0-9-]{36}(?="" target=)"; RegexOptions options = RegexOptions.None; Regex regex = new Regex(pattern, options); MatchCollection matches = regex.Matches(input); foreach (Match match in matches) { Console.WriteLine(match.Value); } } }} string sid = ""; string yourStr = "<a href=\"http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe\" target=\"_blank\">......;" Match mc = Regex.Matche(yourStr, "<a\\s+href=\"(?<URL>.+)&FamilyID=(?<name>.+)\">"\s+target=\"_blank\">......;", RegexOptions.IgnoreCase); if(mc == null) {} else { sid = m.Groups["name"].Value;// } string strReg = "<a href=\"http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe\" target=\"_blank\">";strReg = Regex.Replace(strReg,@"<a\s+href=.*FamilyID=(?<a>[^\"]*?)\"\s+target=\"_blank\">", ${a},RegexOptions.IgnoreCase | RegexOptions.Compiled);可得到211a9c07-88ff-4ae4-a82a-ce2045c6c4fe 关于DataTime的比较 或加减问题?????? C#或者WPF放大镜效果思路(0.0) 简单的问题:只有字母(开头必须是字母)、数字和“/”组成的正则表达式 急:关于vs.net生成文档 !!!!还是没有解觉图象的问题???? 如何在SQL语句里使用函数?如求平均、求和、计数等? 关于亚马逊MWS API开发的,有在做一块的吗? 送分,string[]问题; 送分,进来有分 怎么在.Net2003中让DataGird的行被选中? ■■■有高手吗,我这问题问了四回了,还没答案 怎样在treeview的+/-后面加入图片,就像资源管理器那样的形式
MatchCollection mc = Regex.Matches(yourStr, "<a\\s+href=\".+?&FamilyID=(.+?)\".+?>", RegexOptions.IgnoreCase);
foreach(Match m in mc)
{
m.Groups[1].Value;//
}
using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;namespace RegexTest
{
public class RegexTest
{
public void Test()
{
string input = @"<a href=""http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe"" target=""_blank"">下载此更新"; string pattern = @"(?<=&FamilyID=)[a-zA-Z0-9-]{36}(?=" target=)";
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(pattern, options);
MatchCollection matches = regex.Matches(input); foreach (Match match in matches)
{
Console.WriteLine(match.Value);
}
}
}
}
using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;namespace RegexTest
{
public class RegexTest
{
public static void Main()
{
string input = @"<a href=""http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe"" target=""_blank"">下载此更新"; string pattern = @"(?<=&FamilyID=)[a-zA-Z0-9-]{36}(?="" target=)";
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(pattern, options);
MatchCollection matches = regex.Matches(input); foreach (Match match in matches)
{
Console.WriteLine(match.Value);
}
}
}
}
string yourStr = "<a href=\"http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe\" target=\"_blank\">......;"
Match mc = Regex.Matche(yourStr, "<a\\s+href=\"(?<URL>.+)&FamilyID=(?<name>.+)\">"\s+target=\"_blank\">......;",
RegexOptions.IgnoreCase);
if(mc == null)
{}
else
{
sid = m.Groups["name"].Value;//
}
string strReg = "<a href=\"http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=211a9c07-88ff-4ae4-a82a-ce2045c6c4fe\" target=\"_blank\">";strReg = Regex.Replace(strReg,@"<a\s+href=.*FamilyID=(?<a>[^\"]*?)\"\s+target=\"_blank\">", ${a},RegexOptions.IgnoreCase | RegexOptions.Compiled);可得到211a9c07-88ff-4ae4-a82a-ce2045c6c4fe