Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save luisintosh/8524bad95865b9576b2d8295513b1beb to your computer and use it in GitHub Desktop.

Select an option

Save luisintosh/8524bad95865b9576b2d8295513b1beb to your computer and use it in GitHub Desktop.
const regex = /[?&]tag=([a-zA-Z0-9\-]+)/;
const str = `https://www.amazon.com.mx/Hewlett-Packard-14-av006la-Port%C3%A1til-Pavilion/dp/B01GV7OOCU/ref=s9_simh_gw_g147_i2_r?pf_rd_m=AVDBXBAVVSXLQ&pf_rd_s=&pf_rd_r=YAMKESSPKDXG1&tag=offer10b0b-20&pf_rd_t=36701&pf_rd_p=fe19d36a-3411-4bce-8ef7-fef09d37fff8&pf_rd_i=desktop`;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment