s = "John Smith, Jane Smith" a = s.scan(/<.+?@.+?>/).map{|e| e[1...-1]} # you can optionally print the addresses on new lines a.each {|e| print e; puts ","} # this prints # john.smith@somewhere.com, # jane.smith@somewhere.com,