const regex = new RegExp('(?i)(http|https|ftp|ftps)://\\S*\\.(exe|hta|htr|scr)(\\S*|\\b|$)', 'gm')
const str = `https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112129934&Email=jn47w%40nih.gov"
https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112131410&Email=james.king%40nih.gov"
http://list.nih.gov/cgi-bin/wa.exe?SUBED1=PHS-AD-PHARMACISTS&A=1
https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112130096&Email=jerry.suls%40nih.gov"
https://web.streamlinevrs.com/pmt_common/d_images/email_186198972.script
http://www.scripps.edu/>
https://oedginnrrl.execute-api.us-east-1.amazonaws.com/v1/readstatus?MailingID=112129882&Email=james.welch%40nih.gov"
`;
// 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