I'm using the RegExp from this SO to shorten string without cutting words. Unfortunately this dont work when there are line breaks in the tested string. Is there a way to shorten string without cutting words and also after at the first line break.
"this is a longish string of \n\n test".replace(/^(.{11}[^\s]*).*/, "$1");
//Expected output: "this is a longish"
//Actual output: "this is a longish test"