Reputation: 6039
This Meteor server code using cheerio to extract text from html:
` const myLines = ResObj.$('.panel-body').text();
Which console.log the following:
Using regex, how can I get only non-empty lines, like:
He is
not happy today
and needs to eay
select
I have tried few things for no avail, like replace(/(\W\r\n)/, "")
and so on...
Upvotes: 1
Views: 200
Reputation: 351128
You could use this:
myLines = '\r\n \r\n He is\r\n \r\n \r\n not happy today\r\n \r\n ';
myLines = myLines.replace(/\s*?(^|\n)\s*/g, '$1');
console.log(myLines);
Upvotes: 1