const regex = new RegExp('(?:\\*\\*\\*trash[0-9]+\\*\\*\\*)(\\w+\\s\\w+)(?:\\s[^\\D]+\\s)', 'gm')
const str = `random text 1***trash24***y6f dhy 63 month ago 14 minutes, 29 seconds 3,620 name***trash3***random text 1","random text 2***trash2***pot 5aq 3 months ago 9 minutes, 9 seconds 226,629 name***trash3***random text 2","random text 3***trash2***uan 4fp 5 months ago 26 minutes 506,950 name***trash3***random text 3"
и тут тоже \$1 то что тебе нужно
`;
// 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