I am exporting string to csv and have been removeing new lines and commas like so
thing.toString().replace(/\n/g, '').replace(',','') ;
how can I do this iwthout losing the line breaks and commas? I can't have them in atm because messes up the csv.
Ditch CSV and try a more robust format like JSON:
Otherwise for superior situations, use the binary AMF protocol.
JSON is for 'transfering' information that can be reassembled into number, string, array, object, etc. format afterwards.
Excel can import CSV but it might not understand the complexity of the information. Tyically what you would do is serialize complex information with JSON, recieve it on the other side (wherever that might be) and then deserialize it. After you deserialize it using JSONs abilities to turn your information back into what is was (numbers, strings, arrays and object) it is up to you how you restructure the data for the format you choose.
Your original intent of preserving CSV is best for Excel or OpenOffice Calc. You didn't mention your intent. JSON would package those (CRLF) \n's for you.
Europe, Middle East and Africa