0

私は C# で RSS リーダーを持っています。私の問題は、フィードに画像を表示するサイトもあるということですが、私はそれを必要としません。このサイトのニュースの説明は次のようになります。

/calcio/calciomercato/2013/09/01-271389/Calciomercato?rssimage This is the actual news...
/calcio/calciomercato/2013/08/01-271389/Notizia?rssimage This is the real news...
/calcio/calciomercato/2013/05/01-271389/Esempio?rssimage The news...

実際のニュースの前にすべてのテキストを削除するにはどうすればよいですか? すべての「不要な部分」は「?rssimage」で終わるので、前のすべてのテキストを削除するにはどうすればよいですか? また、ニュースにこの望ましくないテキストが含まれているかどうかを確認するにはどうすればよいですか?

ありがとうございました!

編集: これは RSS です: http://tuttosport.feedsportal.com/c/34178/f/619230/index.rss

これは決定された出力です: Gli emiliani vogliono un attaccante: il sogno resta Belfodil, un'ipotesi concreta è Floro Flores, ma c'è anche il cileno dell'Universidad

I biancoscudati sognano il grande colpo:operazione però difficile perchè Sartori dovrebbe poi trovare il sostituto proprio in extremis

L'attaccante finora è stato poco impiegato tra i titolari, potrebbe andare a fare esperienza: i friulani lo hanno proposto al Bologna a titolo temporaneo

4

2 に答える 2

3

とても単純なのでRegex、 は必要ありません。いくつかのstring methods:

int i = line.IndexOf("?rssimage");
if(i != -1) line = line.Substring(i+8).TrimStart();
于 2013-09-01T16:10:00.193 に答える
3

試す:

string input = "/calcio/calciomercato/2013/09/01-271389/Calciomercato?rssimage This is the actual news...";
string output = Regex.Replace(input, @"(.*?)\?rssimage ", string.Empty);

using System.Text.RegularExpressions;コード ファイルの opに追加することを忘れないでください。

于 2013-09-01T16:11:17.887 に答える