const regex = /href\s?=\s?"\s?([\S\s]+)"/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('href\\s?=\\s?"\\s?([\\S\\s]+)"', 'g')
const str = `href="http://somedomain.com/subscription/some-report-text/issue/the-deadliest-word-on-the-
planet-could-bring-savvy-investors-extraordinary-profits/?u=000071340856&vid=TatDiU&a=MMP&o=9637385?u=000071340856&vid=8ALdFM&a=MMP&o=6530827?u=000071340856&vid=9Vm2j_&a=MMP&o=1652570?u=000071340856&vid=Cd_ME9&a=MMP&o=8995371"`;
// 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