re = /[^\/]*/m
str = '3682/miniperfume-candy.jpg
3681/miniperfume-candy.jpg
4252/parfem-acqua-woman.jpg
4253/parfem-acqua-woman.jpg
3658/miniperfume-acqua-woman.jpg
3659/miniperfume-acqua-woman.jpg
3798/50ml-adriana.jpg
2103/miniparfemy-adriana.jpg
2104/miniparfemy-adriana.jpg
4254/parfem-adriana.jpg
4255/parfem-adriana.jpg
3800/50ml-adriana-rose.jpg
3801/50ml-adriana-rose.jpg
4256/adriana-rose.jpg
4258/adriana-rose.jpg'
# 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