const regex = /.*\:\/\/(?:www.)?([^\/]+)(\/.+")/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('.*\\:\\\/\\\/(?:www.)?([^\\\/]+)(\\\/.+")', 'gm')
const str = `<a href="https://nova.rambler.ru/search?query=Наталия%20Михайловна%20Дудинская&utm_source=search&utm_medium=enser&utm_campaign=self_promo&utm_content=search">
<a href="https://search.rambler.su/static/search/2852365218/css/main.min.css">
<a href="https://static.rambler.ru">
<a href="https://mail.rambler.ru/?utm_source=search&utm_campaign=self_promo&utm_medium=topline&utm_content=mail">
<a href="//ssp.rambler.ru/capirs_async.js">
<a href="https://vk.com/ekalashnikov81">
<a href="https://vk.com/ekalashnikov81/">
<a href="/saved?lang=ru&fmode=inject&tm=1567237779&tld=ru&la=1566641408&text=Kalashnikov%2CEvgenii&url=https%3A%2F%2Fvk.com%2Fekalashnikov81&l10n=ru&mime=html&sign=287b46925db7ebc34c2171935fd60ead&keyno=0">`;
// 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