const regex = /\n/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\n', 'gm')
const str = `zoom Account
thomas.quelle@wissens-piloten.de
iJ&US*5X!^A@@2tk9!42
WL - tq@itworks-rahden.de
DV
Drohneweg 10
32369 Rahden
NextCloud Austauschordner
https://cloud.wissens-piloten.com/index.php/s/qF79YGHk6Ds9ytX
Passwort: B+ek:=,)iP^=9XM^dV&Y2902
Test Von Thomas Q. `;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions