re = /to=<(?P<email>\S+)>,\srelay=(?!10\.10\.10\.).+dsn=(?P<dsn>\d+\.\d+\.\d+),\sstatus=(?!sent)/
str = '2016-10-17T00:00:00.028777+03:00 postfix/smtp[6628]: 878A13DCA5: to=<govorok@gmail.com>, relay=gmail-smtp-in.l.google.com[173.194.220.27]:25, delay=0.47, delays=0.01/0/0.12/0.35, dsn=2.0.0, status=sent (250 2.0.0 OK 1476651600 79si16679285lja.36 - gsmtp)
2016-10-17T00:00:00.029273+03:00 postfix/qmgr[4674]: 878A13DCA5: removed
2016-10-17T00:00:00.037122+03:00 postfix/smtpd[6697]: 0906DA5: client=unknown[192.168.2.74]
2016-10-17T00:00:00.039621+03:00 postfix/cleanup[6713]: 0906DA5: message-id=<20161016210000.0906DA5@mrelay-h3.hh.ru>
2016-10-17T00:00:00.040403+03:00 postfix/smtp[6690]: C5670B9: to=<daler_rajabov@inbox.ru>, relay=mxs.mail.ru[217.69.139.150]:25, delay=0.23, delays=0.01/0/0.02/0.2, dsn=2.0.0, status=1s3ent (250 OK id=1bvsXH-0003Cb-Rp)'
# 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