re = /^(.*?)\/(.*?),now\s(.*?)\s(.*?)\s/
str = 'usbmuxd/kali-rolling,now 1.1.0-2+b1 amd64 [installed,automatic]
usbutils/kali-rolling,now 1:007-4 amd64 [installed]
util-linux/kali-rolling,now 2.28-6 amd64 [installed]
uuid-runtime/kali-rolling,now 2.28-6 amd64 [installed,automatic]
va-driver-all/kali-rolling,now 1.7.1-2 amd64 [installed,automatic]
vboot-kernel-utils/kali-rolling,now 0~R52-8350.B-1 amd64 [installed,automatic]
vboot-utils/kali-rolling,now 0~R52-8350.B-1 amd64 [installed,automatic]
vdpau-driver-all/kali-rolling,now 1.1.1-3 amd64 [installed,automatic]
'
# 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