const regex = /(\/(static)\/)(.*)([0-9]{13}\/)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\\/(static)\\\/)(.*)([0-9]{13}\\\/)', 'g')
const str = ` <link>http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/59fa119a24a694d3151e9f79/1509632943781/medellin-flower-festival-colombia-conde-nast-traveller-1april14-rex_-1.jpg</link>
<title>attachment-59fa119a24a694d3151e9f79</title>
<img src="http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/5a007536e4966b51e8d63db6/1509979480047/buenos-aires-unsettled-argentina-retreat-digital-nomad.jpgbuenos-aires-unsettled-argentina-retreat-digital-nomad?format=original" alt=""/>
<img src="http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/5a007536e4966b51e8d63db6/1509979480047/buenos-aires-unsettled-argentina-retreat-digital-nomad.jpgbuenos-aires-unsettled-argentina-retreat-digital-nomad?format=original" alt=""/>
"http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/59fa1b0b71c10b694346e433/1509563194043/22860715_372374486541985_6060851298842968064_n.jpg",`;
// 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