Вопрос

I cant seem to find what has changed with the latest bing API update. I haven't updated my app in a while, and my once before regular expression is no longer stripping the tags from the IRouteService Response!

//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);

Unexpected Results:

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.

Expected Results

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.

Was wondering if something obvious is sticking out to you guys! Thanks for looking.

Это было полезно?

Решение

You are missing the ", , and = characters from your character class - they are part of the attributes on the tag. Use this:

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

Edit: My first post included the ' character that I used to test with instead of the " character - I've updated the code.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top