I need a javascript to split newline characters with commas. The below one, I am able to split white space and not the new line. Can anyone help me?
Enter Code:
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.
Girish SapariyaPosted Nov 20, 2013, 6:11 AM
var lines = str.split(/[' ', '\n']+/);
\n represents newLine. Try it, and let us know if it works.
Vignesh KumarPosted Nov 20, 2013, 6:23 AM
this
var lines = data.split(' ');
to
var lines = data.split('\n ');