re = /.*(\?)/
str = '/maple-lodge-luxury-bed-and-breakfast/hotel/wanaka-nz.html?asq=1rrVgHWD%2ftbMPIK6tfFoOBewg1Z5%2buLS%2bSEDbaA%2fbS1Cje5wmB0pR0%2bLKktHrg4HC2IQVGwjWisHJHwdUYn88XKp1eogKj%2fzaqwNenpp8R5J8sYcWQ4ELgyWRz8zKFhqCpAzJy%2bIPcIhZIlXClDyysYo7iqvOXmWbg%2fTJAqzGDB7np8MbTsvr9hmeUc%2bP9lIlRlyZyrcrq%2fMBp7AbaEJbA%3d%3d&hotel=99830&tick=637329177909'
# Print the match result
str.match(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