I have a string from which I need to remove some characters that end in backslash doublequote. There are multiple matches. I have it to where it ALMOST works, except I can't get rid of the last backslash double quote (\") in each place that the namespace occurs.
I went to regexpal.com and came up with this regex string that does what I want.
xmlns=*.+be/\\"
But when I put it in C# the two backslashes make it grab way too much. This code repeats my issue and shows my progress:
var str = "<Request> <sender xmlns=\"http://stuff.otherstuff.be/\"> <name>Sender name</name> </sender> <addressee xmlns=\"http://some.stuff.be/\"> </addressee> <networkType xmlns=\"http://yet.more.stuff.be/\">11</networkType></Request>";
str = Regex.Replace(str, @"xmlns=.*?\.be/", "", RegexOptions.IgnoreCase);
I wind up with a string that looks like this. I need to modify the regex a bit to also catch the backslash and double quote
<Request>
<sender \">
<name>Sender name</name>
</sender>
<addressee \">
</addressee>
<networkType \">11</networkType>
</Request>
I've tried various combinations of multiple backslashes and multiple double quotes but am not getting it.
I have looked at a lot of answers here and elsewhere, and haven't figured it out, so a "has duplicate" isn't really going to help me.
EDIT: At this point in the code all I have is a string that came from a serialized class. I don't really want to load the string into and XMLDocument and do recursive calls like in the possible answer shown. A quick regex replace should get me what I need in 1 statement.
EDIT: The answer with adding two doublequotes does not help me because it ignores the final backslash that I'm trying to get rid of.