const regex = /\*\*\[(.+)\]> \[([^*]+)\]/gm; const str = `**[Никнейм]> [сообщение]** **[Никнейм2]> [сообщение2]**`; let m; while ((m = regex.exec(str)) !== null) { if (m.index === regex.lastIndex) { regex.lastIndex++; } if(m.length < 3) continue; const nickname = m[1]; const message = m[2]; console.log(nickname); console.log(message); }