3

サブカテゴリが何度も繰り返されたというリンクがあります。また、特定のリストにある場合にのみ繰り返しを保持したい。ただし、リンクの最後の部分も保持してください ビデオについて Example1 Example2

www.example.com/About/About/Videos/Videos/Videos/Featured/5-great-videos

する必要があります

www.example.com/about/videos/5-great-videos

何か助けはありますか?

4

2 に答える 2

2

LINQを使用して、これはどうですか

string str = "www.example.com/About/About/Videos/Videos/Videos/Featured/5-great-videos";
var result = str.Split('/').GroupBy(x=>x).Select(x=>x.Key).Aggregate((a,b)=>a+"/"+b);
于 2013-06-25T00:39:12.607 に答える