用于测试的字符串

string s="uid=aaaaaaaaaaaa</a>||||||||||||||Uid=bbbbbbbbbbbbbbbbbb</a>||||||||||||||Uid=cccccccccccccc</a>||||||||||||||Uid=dddddddddddddddd</a>";

//temp 存放匹配结果
string temp="";

//results 正则捕获结果集合
MatchCollection results =  Regex.Matches(s,"uid=(?<txt>.*?)</a>",RegexOptions.IgnoreCase);

//遍历results集合
foreach(Match m in results)
{
   temp+=m.Groups["txt"].ToString()+"<br/>";//将m中命名为txt的组的捕获内容拼接到temp
}

//输出结果
Response.Write(temp);
Response.End();

原文地址:https://www.cnblogs.com/wangchuang/p/2507398.html