mik888em,
<script>
let text = `Or to take arms against a sea of troubles?
And by opposing end them. To die—to sleep
No more; and by a sleep to say we end.
The heart-ache and the thousand natural shocks
That flesh is heir to: ’tis a consummation!
Devoutly to be wish’d. To die, to sleep;
To sleep, perchance to dream—ay, there’s the rub:
For in that sleep of death what dreams may come
Borne on the bier6 with white and bristly beard:
Then of thy beauty do I question make
`;
let redo = new Set();
let regStr = /(^[\s\S]+\n)(?=(.*?[.,!?"':;”“]\n){3})/mg;
function replace(a, b, c) {
return '';
}
text = text.replace(regStr, replace);
document.write(`<pre>${text}</pre>`)
</script>