Skip to content

Instantly share code, notes, and snippets.

@surajp
Created July 9, 2019 05:49
Show Gist options
  • Save surajp/c14c9ec7f5e534cbb605b5d90f8e53d5 to your computer and use it in GitHub Desktop.
Save surajp/c14c9ec7f5e534cbb605b5d90f8e53d5 to your computer and use it in GitHub Desktop.
Escape new line character within the same row in csv
const cleanFunction = arr=>arr.reduce((clean,current)=>{current.replace(/[^(?<!\\)"]/g,"").length%2>0?clean+=current+"\\n":clean+=current+"\n";return clean},"").replace(/\\n$/,'')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment