const regex = new RegExp('^(?:ht|f)tps?://[^/]+/[^.]+\\.([^?]+)\\?*$', 'gm')
const str = `http://u.example.something.com/abc=aaadddrBccc2SgFV000ALK2Qddd_;_vvv=Yu3DUzBHNlzcHIEY29sYMTEzZHQ5NjUzBHNlY9sbwNiZjEEdnRpZANRMU0wMV8xBHBvcwMx/CC=20/RE=MU0wMV8xBHBvcwMx/UU=10/ZZ=http://hhh.w.example.com/?uv=xxxxxx878787xxxxxxxxjhkjhkjhjkhADFADFS-&u=http://wwww.example.com/%2fuuu-lllllll%2sdfg-afd-adsfadf%2asdfaf000%3asdfasdfasfd%3dbing%26uasdfadf%3dcpc%26asdfadf%3d_ASDF234_ASDF%26asdfasF_asdfasdf%3d%252Bfasdfadsf%2520%252Basdf%2520%252Bdesign%26asdfasdf_aasdf%3dlf9McvAV%7cFADF%7c4063555565%7cpkw%7c%252Bfree%2520%252Bpcb%2520%252Basdf%7casdf%7asdf%7adf%7adf%7c/PO=0/UJ=iasdf7PASDFASDF-?p=this+is+an+example;`;
// 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