re = /(https?:\/\/(?![^\s\/]+youtu)[^\s\)\]?]+)\?([^\s\)\]?]{20,})/m
str = 'https://www.aliexpress.com/item/4000050337687.html?spm=a2g0o.productlist.0.0.70c9492bADfZA5&algo_pvid=66a91537-1872-4a3b-ab39-e9d130970423&algo_exp_id=66a91537-1872-4a3b-ab39-e9d130970423-0&pdp_ext_f=%7B%22sku_id%22%3A%2210000003069527876%22%7D&pdp_npi=2%40dis%21EUR%2118.03%2114.07%21%21%21%21%21%402100bdd816603176696127137ebeac%2110000003069527876%21sea&curPageLogUid=8f5jqvWtAYMa'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html