const regex = /\[(.*?)\]\s\((http.*?)\)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\[(.*?)\\]\\s\\((http.*?)\\)', 'g')
const str = `'[катетер-направленному тромболизису] (https://www.radiologyinfo.org/en/info.cfm?pg=thrombo), но та, которая, помимо удаления тромбов, также открывает и усиливает слишком маленькие кровеносные сосуды через стенты или другие средства. Также может быть желательно увеличить их проницаемость, чтобы фиксаторы достигали паренхимы мозга по всему кровеносному сосуду, а не только на кончиках. Лазер может делать микроскопические дыры по всей длине, а затем, возможно, добавить [тонкий слой полиамида] (https://en.wikipedia.org/wiki/Thin-film_composite_membrane#Structure_and_materials)'`;
// 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