const text = `KI Quiz Teil 2 - jetzt wird's schwerer " " "Letzte Woche haben wir die 5 Einstiegsfragen gesehen: "Viel Vergnügen!`; // Strip trailing quotes let cleaned = text.replace(/ "\n/g, '\n'); // Strip quotes on their own line cleaned = cleaned.replace(/\n"\n/g, '\n'); // Strip leading quotes cleaned = cleaned.replace(/\n"/g, '\n'); console.log(cleaned);