Hi,
I want an regular expression to eliminate the white space from an xml file having style tags.
Eg: "Font-Style : italic" should be converted to "Font-Style:italic"
How can i achieve this?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Feb 8, 2013, 5:00 AM
However, there's no need to use it anyway as this should work fine:
string output = Regex.Replace(input, @"\s*:\s*", ":").Trim();
Salma SiddiqaPosted Feb 8, 2013, 1:50 AM
Thank you for your replies .
I could resolved this using the following:
string output=new StringBuilder(Regex.Replace(input, @"\s*:\s*", ":").Trim());
Salma SiddiqaPosted Feb 7, 2013, 11:32 PM
My requirement is to search for " : " in an xml file and remove the space.
Jignesh TrivediPosted Feb 7, 2013, 10:58 PM
try...
var myString = "Font-Style : italic";
myString = Regex.Replace(myString, @"[ ]", string.Empty, RegexOptions.Multiline);
hope this will help you.
VulpesPosted Feb 7, 2013, 10:07 AM
For example, this code will get rid of white space for any tag which ends with '-Style':