JSFiddle - React, Tailwind, and code Playground

JavaScript

infotext="this is a longish string of test.\n bla bla bla bla text here";
infotext = infotext.replace(/^([\s\S]{10}\S*)[\s\S]*/gim, "$1");
console.log(infotext);