re = /^(?:ht|f)tps?:\/\/[^\/]+\/[^.]+\.([^?]+)\?*$/m
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;'
# 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