const splitText = (string) => { const newText = string .split(/((?:w+ ){1})/g) .filter(Boolean) .join(" "); return newText }; console.log(splitText("Hello, world")); //Hello, //world