110,538
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
Regex.Matches(html, @"<li\b[^<>]*?>[\s\S]*?</li>").Cast<Match>().OrderBy(m => Guid.NewGuid())
结果string.join下string s = "<li>111</li><li>222</li><li>333</li> <li>444</li>";
Console.WriteLine(s);
var a = Regex.Matches(s, @"<li>\w+</li>");
var f = a.Cast<Match>().Select(m => m.Value).ToList();
List<int> indices = new List<int>();
for (int i = 0; i < f.Count; i++)
{
indices.Add(i);
}
Random r = new Random();
string d = "";
for (int i = 0; i < f.Count; i++)
{
int j = indices[r.Next(indices.Count)];
d += f[j];
indices.Remove(j);
}
Console.WriteLine(d);