re = /(?:.+(?:\/|%2F))+?([^\/]+\.jpg)(?=\?)/m
str = 'https://firebasestorage.googleapis.com/v0/b/work-52105.appspot.com/o/user%2FwCBsmRGAxbMQXO2yqc8jF65pmIG3%2FDepositphotos_59984669_s-2015.jpg?alt=media&token=916f8bb6-2ccf-4a95-b76b-814db081c028'
# 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