110,546
社区成员
发帖
与我相关
我的任务
分享
List<string> list = new List<string>();
list.Add("第1章 aaaaaaa第1章bbbbbb第2章c 第1章");
list.Add("第2章bbbbb ccccccc");
list.Add("第100章 第100章第100章第100章 第100章 dddd");
Regex reg = new Regex(@"^[^\s]+");
for (int i = 0; i < list.Count; i++)
list[i] = reg.Replace(list[i], "<br>$0</br>");
for(int i=0;i<list.Count;i++)
{
list[i] = Regex.Replace(list[i],"^第[^章]+章","<br>$&</br>");
}
for(int i=0; i<list.Count; i++)
{
list[i] = Regex.Replace(list[i], @"(?<=").*?(?= )", "<br>$&</br>");
}