Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2019 08:10 PM
Hi - I want to convert below lines to single line. Is this something possible with JavaScript?
This is line one
This is line two
This is a broken line
This is line three
Expected output:
This is line one, This is line two This is a broken line, This is line three
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2019 08:31 PM
Try this out
var line = '';
var lines = multiLines.split("\n"); //multiLines contains your text
for(var i=0; i<lines.length; i++){
if(lines[i].startsWith(" ")){
line += " " + lines[i].trim();
}else{
line += "," + lines[i].trim();
}
}
line = line.substring(1).trim();
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2019 08:35 PM
Great! That works.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2019 08:45 PM
Hi
Please see this thread for that :
https://stackoverflow.com/questions/32309670/change-multi-line-strings-to-single-line
Please mark as correct if it is helpful for you .
Thanks
Sanjay Bagri
Dxsherpa.com