JavaScript Removing only empty line break, preserving spaces

I'm trying to remove extra line breaks, so that texts are one after another, while preserving white spaces (used as indents)

I have the following:

report_text = report_text.split("\n").map($.trim).filter(function(line) { return line != "" }).join("\n");

which will return with lines of text one after another (which is correct), but will also remove my indents (two or more white spaces) because of the $.trim

I don't know of any other way to keep my "indents" and just only remove empty line breaks. Is there a way I can have each line of line string one after another, but preserve all my white spaces.

Answer:1

How about simply report_text.replace(/\n+/g, "\n")?

Answer:2

I'm a totally new to coding and Google App script, so I humbly ask my question. I have look all over the place for an answer to this problem and can't seem to find a way to solve it. Below is my ...

I'm a totally new to coding and Google App script, so I humbly ask my question. I have look all over the place for an answer to this problem and can't seem to find a way to solve it. Below is my ...

i am trying to check if an url is online. I use the $new_url for the url that the user gives. The problem that i face is that i always take a 404 either the url is online either not... <?php ...

i am trying to check if an url is online. I use the $new_url for the url that the user gives. The problem that i face is that i always take a 404 either the url is online either not... <?php ...

  1. ajax check username exists
  2. ajax check file exists
  3. ajax check url exists
  4. ajax check image exists
  5. ajax check user exists
  6. ajax check if file exists
  7. ajax check if username exists
  8. ajax check if data exists
  9. ajax check if url exists
  10. ajax check if email exists in database
  11. ajax check if value exists in database
  12. ajax check if element exists
  13. ajax check if file exists on server
  14. ajax check if image exists
  15. ajax check if id exists
  16. ajax check if class exists
  17. ajax check if record exists
  18. ajax check if page exists
  19. ajax check if session exists
  20. ajax check if div exists

I am trying to limit the number of checkboxes a user can select. These checkboxes are DOM input objects generated for each item in an array. I'm having no luck with this currently, so any help is ...

I am trying to limit the number of checkboxes a user can select. These checkboxes are DOM input objects generated for each item in an array. I'm having no luck with this currently, so any help is ...

I'm working on a web app which implements a wizard-like behavior. it uses an API to get the "wizard" steps. the API works in a way where you send a request with the current step and all previous ...

I'm working on a web app which implements a wizard-like behavior. it uses an API to get the "wizard" steps. the API works in a way where you send a request with the current step and all previous ...

  1. angular router dynamic path
  2. angular router dynamic routes
  3. angular router dynamic data
  4. angular router dynamic component
  5. angular router dynamic redirect
  6. angular router dynamic
  7. angular router dynamic parameters
  8. angular router dynamic redirectto
  9. angular router dynamic url
  10. angular router dynamic link
  11. angular routing dynamic url
  12. angular routing dynamic
  13. angular routing dynamic path
  14. angular routing dynamic component
  15. angular routing dynamic data
  16. angular routing dynamic parameter
  17. angular routing dynamic template
  18. angular dynamic router outlet
  19. angular dynamic router outlet name
  20. angular dynamic router module