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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Girish Sapariya159 reputationPosted Nov 20, 2013, 1:11 AM EST
var lines = str.split(/[' ', '\n']+/);
\n represents newLine. Try it, and let us know if it works.
Vignesh KumarRank #1,578 · 1K reputationPosted Nov 20, 2013, 1:23 AM EST
this
var lines = data.split(' ');
to
var lines = data.split('\n ');