re = /(?:(?:.*?,){6})(?<email>.*?),(?:(?:.*?,){2})(?<phone>.*?),.*$/m
str = '55451,31.173.84.144,Ирина,10,100medspravok.com,,rinazhukova77@gmail.com,МСК,1481572814,9265837548,778899,1,0,1
55452,149.13.91.87,Антон,0,100medspravok.com,,adm.bitgram@gmail.com,МСК,1481572822,9111460148,ДшЫЙ7рйо,0,1,1'
# 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