const regex = /\??(
((action_)((object)|(type)|(ref))(_map))|
(spm)|(scm(\-|_)(.*?))|(aff_)(.*?)|(algo_)(.*?)|(btsid)|(ws_)(.*?)|
(pd_rd_)(.*?)|(_encoding)|(psc)|(tag)|(ref_)|(pf)|(pf_rd_)(.*?)|
(callback)|
(cvid)|(form)|(sk)|(sp)|(qs)|(pq)|
(mkt_tok)|
(trk(Campaign)?)|
(ga_)(.*?)|(gclid)|(gclsrc)|
(hmb_)((campaign)|(medium)|(source))|
((sp)((Report)|(Job)|(User)|(Mailing))(ID))|
(itm_)(.*?)|
(s_cid)|
(elq((Track)?Id)?)|(elqTrack)|(assetType)|(assetId)|(recipientId)|(сampaignId)|(siteId)|
(mc_(c|e)id)|
(pk_)(.*?)|
(sc_)(.*?)|
(utm_)(.*?)|(nr_email_referer)|
(vero_(.*?))|
(nr_)(.*?)|
(yclid)|(_openstat)|(lr)|(redircnt)|
(mbid)|(cmpid)|(cid)|(c_id)|(campaign_id)|(Campaign)|
(fb_)(.*?)|(fbclid)|(f?ref)|(refsrc)|(hrc)|
(gw?s_)(.*?)|(ved)|(s?ei)|
(_hsenc)|(_hsmi)|(__hssc)|(__hstc)|(hsCtaTracking)|
(source)|(position)|
(tt_)(.*?)|
(wt_)(.*?)|
(hc)|(fb)|(yc)|(fan)|(asb)|(asb2)|(mindbox)|(from)|(sh)|(keywords?)|(feature)|(mlid)|(stid)|(topnews_)(.*?)|(persistent_)(.*?)|(msid)|(rubric)|(lang)|(t?t=)(.*?)|(d)|(s)|(psf)|(sourceType)|(short)|(pdp_ext_f)|(utparam)|(pvid))(=(.*?)|(?=(&|$|\r|\n|")))(?=(&|$|\r|"|\n))/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\??(
((action_)((object)|(type)|(ref))(_map))|
(spm)|(scm(\\-|_)(.*?))|(aff_)(.*?)|(algo_)(.*?)|(btsid)|(ws_)(.*?)|
(pd_rd_)(.*?)|(_encoding)|(psc)|(tag)|(ref_)|(pf)|(pf_rd_)(.*?)|
(callback)|
(cvid)|(form)|(sk)|(sp)|(qs)|(pq)|
(mkt_tok)|
(trk(Campaign)?)|
(ga_)(.*?)|(gclid)|(gclsrc)|
(hmb_)((campaign)|(medium)|(source))|
((sp)((Report)|(Job)|(User)|(Mailing))(ID))|
(itm_)(.*?)|
(s_cid)|
(elq((Track)?Id)?)|(elqTrack)|(assetType)|(assetId)|(recipientId)|(сampaignId)|(siteId)|
(mc_(c|e)id)|
(pk_)(.*?)|
(sc_)(.*?)|
(utm_)(.*?)|(nr_email_referer)|
(vero_(.*?))|
(nr_)(.*?)|
(yclid)|(_openstat)|(lr)|(redircnt)|
(mbid)|(cmpid)|(cid)|(c_id)|(campaign_id)|(Campaign)|
(fb_)(.*?)|(fbclid)|(f?ref)|(refsrc)|(hrc)|
(gw?s_)(.*?)|(ved)|(s?ei)|
(_hsenc)|(_hsmi)|(__hssc)|(__hstc)|(hsCtaTracking)|
(source)|(position)|
(tt_)(.*?)|
(wt_)(.*?)|
(hc)|(fb)|(yc)|(fan)|(asb)|(asb2)|(mindbox)|(from)|(sh)|(keywords?)|(feature)|(mlid)|(stid)|(topnews_)(.*?)|(persistent_)(.*?)|(msid)|(rubric)|(lang)|(t?t=)(.*?)|(d)|(s)|(psf)|(sourceType)|(short)|(pdp_ext_f)|(utparam)|(pvid))(=(.*?)|(?=(&|$|\\r|\\n|")))(?=(&|$|\\r|"|\\n))', 'g')
const str = `https://yandex.ru/news/story/Prezident_Tokaev_prinyal_otstavku_pravitelstva_Kazakhstana--243e04d37f1419500c9ece814c1d9e30?lang=ru&rubric=index&fan=1&stid=byyvfKwXr5iSKBBZZOVN&t=1641352850&tt=true&persistent_id=176465644&
https://www.aliexpress.com/item/4000317035065.html?pdp_ext_f=%7B%22ship_from%22%3A%22CN%22%2C%22sku_id%22%3A%2212000018551624449%22%7D&sourceType=fd&scm_id=1007.28480.226530.0&scm-url=1007.28480.226530.0&pvid=4ae1761c-d2f8-43f3-a91d-68763fb50e0b&utparam=%257B%2522process_id%2522%253A%2522110%2522%252C%2522x_object_type%2522%253A%2522product%2522%252C%2522pvid%2522%253A%25224ae1761c-d2f8-43f3-a91d-68763fb50e0b%2522%252C%2522belongs%2522%253A%255B%257B%2522id%2522%253A%25224001%2522%252C%2522type%2522%253A%2522dataset%2522%257D%255D%252C%2522scm%2522%253A%25221007.28480.226530.0%2522%252C%2522tpp_buckets%2522%253A%252221669%25230%2523186385%25230_21669%25234190%252319163%2523569_15324%25230%2523132599%25230%2522%252C%2522x_object_id%2522%253A%25224000317035065%2522%257D`;
// 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