c# - How would you approach this simple string parsing problem? -
"\n \n expected:\n \n \n q4\n \n \n 2011\n \n "
from string, need following:
"expected q4 2011"
i've tried following , no dice:
mystring.trim().replace("\n", "");
i following (the massive whitespace intentional , not site formatter issue. in fact returned.)
"expected: q4 2011"
replace white space blocks single space:
mystring = regex.replace(mystring, @"\s+", " ").trim();
Comments
Post a Comment