I have an XML document with element names with a space or multiple spaces in it (which is not allowed in XML) and I am looking for a regex to replace the space with an _ and after modifications replace the _ with a space again. The regex can be applied to a string.
Simplified Sample XML where I want to replace <User Blob> to <User_Blob> but I don’t want to replace eg My Space to My_Space. So the RegEx needs to match a < followed by one or more words with a space in it, followed by > I think.
<User Data Blob>
<Item>
<Key>SomeKey</Key>
<Value>false</Value>
</Item>
<Item>
<Key>AnotherKey</Key>
<Value></Value>
</Item>
</User Data Blob>
1 Answer