Forum Discussion

DanNad's avatar
DanNad
Contributor
2 years ago

How to remove/replace empty lines from string?

Hello all

 

i cant get the empty lines to be removed.

Example:
i have a String like this:
Example:
Object is: page.querySelectorAll("*")[0].innerText
the innerText i get is similar to this:

Test Text



Test Text

Test Text



Test Text


Test Text Test Text

 
i want the text to be this:

Test Text
Test Text
Test Text
Test Text
Test Text Test Text


i tried to find a way with aqString methods but i just cant find a good way to remove the empty line.

what i try to accomplish is to get all the text from a page and save it to a simple text file

Is there a way to do this?
Help would be very much appreciated.