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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -