re = /sm-mta\[.*\]:\s(?<qid>.*?):/m
str = 'Feb 19 00:05:04 smtp2 sm-mta[28608]: l1J652ZW028608: from=<dsbugeyed@example.org>, size=15433, class=0, nrcpts=1, msgid=<001001c75437$5633fa90$06aeb57c@samsungtkb30u2>, proto=SMTP, daemon=MTA, relay=[58.78.156.175]'
# 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