Regex returns escaped match in .NET - why?
As you can see in the screenshort, capture captures the right value Boton \"Reservar\", but that property doesn't seem to be available. Value returns that value but escaped, that's not what I need. Is this the normal behavior with .NET? It's usually the case that Value shows the same value as the object string, but this time it's escaped.
Also, as you can see in the Immediate Window, capture.ToString() and even group shows the value escaped.
Worse yet, Value is wrapped in quotes, which is not what the regex is supposed to match.
I already tried casting capture to Group and calling capture.C开发者_开发百科aptures again to see if the real match is hidden in deeper groups but it isn't.
Any ideas?
The string in memory is correct - it's just its representation in the immediate / watch / locals window which is escaped. I don't know why the people from Visual Studio decided to do that, but one possible explanation is that you can copy that string as is and paste in your code:
var match = "Botón \\\"Reservar\\\"";
And it will have the actual value of the capture. If you click on the magnifying glass next to the value of the "Value" property you'll see the string without the escaping.
精彩评论