62,047
社区成员
发帖
与我相关
我的任务
分享
string str = "<form name=\"kenoresults\"><input type=\"hidden\" name=\"kr\" value=\"2590,14,04,30;68,43,61,49,52,73,23,2,6,32,79,30,31,77,70,69,9,45,1,26:2589,14,01,00;69,24,53,2,20,8,31,1,27,26,59,30,19,56,73,79,16,46,57,10:2588,13,57,30;76,31,8,9,13,54,72,51,26,11,27,36,80,15,12,38,64,5,28,37:2587,13,54,00;58,32,61,18,76,67,31,69,13,27,5,66,57,62,33,63,44,19,53,1:2586,13,50,30;20,79,73,56,80,58,23,1,45,78,3,53,76,67,66,10,60,41,36,25:2585,13,47,00;7,27,15,20,5,40,6,72,34,16,51,22,46,37,78,47,10,77,29,57:2584,13,43,30;80,3,54,73,5,61,55,44,65,63,33,56,6,20,14,21,15,29,67,38:2583,13,40,00;39,78,48,4,45,22,25,31,66,71,18,74,61,55,62,68,10,5,80,42:2582,13,36,30;73,56,28,3,42,49,36,48,14,80,17,7,24,44,62,46,33,76,41,8:2581,13,33,00;62,76,77,17,63,24,12,41,7,78,59,53,55,10,72,75,21,43,51,68:2580,13,29,30;24,65,73,54,26,62,28,7,8,25,37,22,67,14,15,74,5,1,80,38:2579,13,26,00;7,73,41,69,74,66,78,33,3,4,5,77,20,70,71,28,63,38,53,44:2578,13,22,30;48,78,22,3,63,60,21,65,46,37,72,31,45,18,55,70,12,44,10,8:2577,13,19,00;48,38,15,3,6,23,32,35,49,25,65,1,63,24,45,20,17,52,75,31:2576,13,15,30;52,49,39,7,14,12,26,34,70,24,77,46,79,74,11,15,40,76,27,10:\"></form>";
Regex reg = new Regex(@"(?is)<input[\s\S]+?value=""(.+?)""[\s\S]+?>");
foreach (Match m in reg.Matches(str))
{
string[] arrstr = m.Groups[1].Value.Split(':');
for (int i = 0; i < arrstr.Length; i++)
{
Response.Write(arrstr[i]+ "<br/>");
}
}
/*
2590,14,04,30;68,43,61,49,52,73,23,2,6,32,79,30,31,77,70,69,9,45,1,26
2589,14,01,00;69,24,53,2,20,8,31,1,27,26,59,30,19,56,73,79,16,46,57,10
2588,13,57,30;76,31,8,9,13,54,72,51,26,11,27,36,80,15,12,38,64,5,28,37
2587,13,54,00;58,32,61,18,76,67,31,69,13,27,5,66,57,62,33,63,44,19,53,1
2586,13,50,30;20,79,73,56,80,58,23,1,45,78,3,53,76,67,66,10,60,41,36,25
2585,13,47,00;7,27,15,20,5,40,6,72,34,16,51,22,46,37,78,47,10,77,29,57
2584,13,43,30;80,3,54,73,5,61,55,44,65,63,33,56,6,20,14,21,15,29,67,38
2583,13,40,00;39,78,48,4,45,22,25,31,66,71,18,74,61,55,62,68,10,5,80,42
2582,13,36,30;73,56,28,3,42,49,36,48,14,80,17,7,24,44,62,46,33,76,41,8
2581,13,33,00;62,76,77,17,63,24,12,41,7,78,59,53,55,10,72,75,21,43,51,68
2580,13,29,30;24,65,73,54,26,62,28,7,8,25,37,22,67,14,15,74,5,1,80,38
2579,13,26,00;7,73,41,69,74,66,78,33,3,4,5,77,20,70,71,28,63,38,53,44
2578,13,22,30;48,78,22,3,63,60,21,65,46,37,72,31,45,18,55,70,12,44,10,8
2577,13,19,00;48,38,15,3,6,23,32,35,49,25,65,1,63,24,45,20,17,52,75,31
2576,13,15,30;52,49,39,7,14,12,26,34,70,24,77,46,79,74,11,15,40,76,27,10
*/
string regtxt = "<form name=\"kenoresults\">"
+ "<input type=\"hidden\" name=\"kr\" value=\"2590,14,04,30;68,43,61,49,52,73,23,2,6,32,79,30,31,77,70,69,9,45,1,26:2589,14,01,00;69,24,53,2,20,8,31,1,27,26,59,30,19,56,73,79,16,46,57,10:2588,13,57,30;76,31,8,9,13,54,72,51,26,11,27,36,80,15,12,38,64,5,28,37:2587,13,54,00;58,32,61,18,76,67,31,69,13,27,5,66,57,62,33,63,44,19,53,1:2586,13,50,30;20,79,73,56,80,58,23,1,45,78,3,53,76,67,66,10,60,41,36,25:2585,13,47,00;7,27,15,20,5,40,6,72,34,16,51,22,46,37,78,47,10,77,29,57:2584,13,43,30;80,3,54,73,5,61,55,44,65,63,33,56,6,20,14,21,15,29,67,38:2583,13,40,00;39,78,48,4,45,22,25,31,66,71,18,74,61,55,62,68,10,5,80,42:2582,13,36,30;73,56,28,3,42,49,36,48,14,80,17,7,24,44,62,46,33,76,41,8:2581,13,33,00;62,76,77,17,63,24,12,41,7,78,59,53,55,10,72,75,21,43,51,68:2580,13,29,30;24,65,73,54,26,62,28,7,8,25,37,22,67,14,15,74,5,1,80,38:2579,13,26,00;7,73,41,69,74,66,78,33,3,4,5,77,20,70,71,28,63,38,53,44:2578,13,22,30;48,78,22,3,63,60,21,65,46,37,72,31,45,18,55,70,12,44,10,8:2577,13,19,00;48,38,15,3,6,23,32,35,49,25,65,1,63,24,45,20,17,52,75,31:2576,13,15,30;52,49,39,7,14,12,26,34,70,24,77,46,79,74,11,15,40,76,27,10:\">"
+ "</form>";
Regex treg = new Regex(@"(?<txt>[^""]+?(:))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Match tmc=treg.Match(regtxt);
while (tmc.Success)
{
Response.Write(tmc.Groups["txt"] + "<br/>");
tmc = tmc.NextMatch();
}
void Main()
{
string str = @"<form name=""kenoresults"">
<input type=""hidden"" name=""kr"" value=""2590,14,04,30;68,43,61,49,52,73,23,2,6,32,79,30,31,77,70,69,9,45,1,26:2589,14,01,00;69,24,53,2,20,8,31,1,27,26,59,30,19,56,73,79,16,46,57,10:2588,13,57,30;76,31,8,9,13,54,72,51,26,11,27,36,80,15,12,38,64,5,28,37:2587,13,54,00;58,32,61,18,76,67,31,69,13,27,5,66,57,62,33,63,44,19,53,1:2586,13,50,30;20,79,73,56,80,58,23,1,45,78,3,53,76,67,66,10,60,41,36,25:2585,13,47,00;7,27,15,20,5,40,6,72,34,16,51,22,46,37,78,47,10,77,29,57:2584,13,43,30;80,3,54,73,5,61,55,44,65,63,33,56,6,20,14,21,15,29,67,38:2583,13,40,00;39,78,48,4,45,22,25,31,66,71,18,74,61,55,62,68,10,5,80,42:2582,13,36,30;73,56,28,3,42,49,36,48,14,80,17,7,24,44,62,46,33,76,41,8:2581,13,33,00;62,76,77,17,63,24,12,41,7,78,59,53,55,10,72,75,21,43,51,68:2580,13,29,30;24,65,73,54,26,62,28,7,8,25,37,22,67,14,15,74,5,1,80,38:2579,13,26,00;7,73,41,69,74,66,78,33,3,4,5,77,20,70,71,28,63,38,53,44:2578,13,22,30;48,78,22,3,63,60,21,65,46,37,72,31,45,18,55,70,12,44,10,8:2577,13,19,00;48,38,15,3,6,23,32,35,49,25,65,1,63,24,45,20,17,52,75,31:2576,13,15,30;52,49,39,7,14,12,26,34,70,24,77,46,79,74,11,15,40,76,27,10:"">
</form>";
foreach(Match m in Regex.Matches(str,@"(?i)<input[^>]*?value=(['""\s]?)([^'""\s]+)\1"))
{
Console.WriteLine(m.Groups[2].Value);
}
/*
2590,14,04,30;68,43,61,49,52,73,23,2,6,32,79,30,31,77,70,69,9,45,1,26:2589,14,01,00;69,24,53,2,20,8,31,1,27,26,59,30,19,56,73,79,16,46,57,10:2588,13,57,30;76,31,8,9,13,54,72,51,26,11,27,36,80,15,12,38,64,5,28,37:2587,13,54,00;58,32,61,18,76,67,31,69,13,27,5,66,57,62,33,63,44,19,53,1:2586,13,50,30;20,79,73,56,80,58,23,1,45,78,3,53,76,67,66,10,60,41,36,25:2585,13,47,00;7,27,15,20,5,40,6,72,34,16,51,22,46,37,78,47,10,77,29,57:2584,13,43,30;80,3,54,73,5,61,55,44,65,63,33,56,6,20,14,21,15,29,67,38:2583,13,40,00;39,78,48,4,45,22,25,31,66,71,18,74,61,55,62,68,10,5,80,42:2582,13,36,30;73,56,28,3,42,49,36,48,14,80,17,7,24,44,62,46,33,76,41,8:2581,13,33,00;62,76,77,17,63,24,12,41,7,78,59,53,55,10,72,75,21,43,51,68:2580,13,29,30;24,65,73,54,26,62,28,7,8,25,37,22,67,14,15,74,5,1,80,38:2579,13,26,00;7,73,41,69,74,66,78,33,3,4,5,77,20,70,71,28,63,38,53,44:2578,13,22,30;48,78,22,3,63,60,21,65,46,37,72,31,45,18,55,70,12,44,10,8:2577,13,19,00;48,38,15,3,6,23,32,35,49,25,65,1,63,24,45,20,17,52,75,31:2576,13,15,30;52,49,39,7,14,12,26,34,70,24,77,46,79,74,11,15,40,76,27,10:
*/
}