0

最新のbing APIの更新で何が変わったのかわかりません。しばらくアプリを更新していませんでしたが、以前の正規表現で IRouteService 応答からタグが取り除かれなくなりました。

//Remove all Bing Maps tags around keywords.  
Regex regex = new Regex("<[/a-zA-Z:]*>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
textBlock1.Text = regex.Replace(directions.ToString(), string.Empty);

予期しない結果:

Leg #1
1. 15.034  Head <VirtualEarth:span class="heading">northeast</VirtualEarth:span>. 
2. 8.4  Turn <VirtualEarth:TurnDir>left</VirtualEarth:TurnDir> 
3. 0  You will reach your destination . The destination is on your left.

予想された結果

Leg #1
1. 15.034  Head northeast. 
2. 8.4  Turn left 
3. 0  You will reach your destination . The destination is on your left.

明らかな何かがあなたたちに突き出ているのではないかと思っていました! ご覧いただきありがとうございます。

4

1 に答える 1

2

"文字クラスの、、および文字がありません=。これらはタグの属性の一部です。これを使って:

Regex regex = new Regex("<[/a-zA-Z:\"' =]+>", RegexOptions.IgnoreCase | RegexOptions.Multiline);

編集:私の最初の投稿には、'文字の代わりにテストに使用した文字が含まれて"いました。コードを更新しました。

于 2013-07-09T16:25:16.370 に答える