-1

I have this type of string in a text file:

First line
Second line

other line
another line

more line
next line

How can I append all the string into a single line ?

the required output is :

First line second line other line another line more line next line

I had try removing white space and append string tutorial but still did not get the required output.

Community
  • 1
  • 1
lighthing
  • 1
  • 1
  • What language are you working on? – Nhan Aug 22 '16 at 06:51
  • have a look at this http://stackoverflow.com/questions/10805125/how-to-remove-all-line-breaks-from-a-string . You need to remove line breaks from your string. – Manish Aug 22 '16 at 06:58

1 Answers1

1

you could replace new line characters with a space:

console.log(txt.value.replace(/[\n\r]/g, ' '));
<textarea id="txt">
First line Second line

other line another line

more line next line
</textarea>
MoLow
  • 3,056
  • 2
  • 21
  • 41