-1

I have a string of email in a variable such as "Bill Warner (abc Ltd.)" <bill@abc.com>, "Paula Warner" <paula@abc.com>

I would like to create an array that extract each of the email and returns ["bill@abc.com","paula@abc.com"]

I find a way to make the extraction, using a custom function:

  def string_between_markers marker1, marker2
    self[/#{Regexp.escape(marker1)}(.*?)#{Regexp.escape(marker2)}/m, 1]
  end

Only issue, is that this works only once. What would be the right method to extract each of the email address please ?

Rene Chan
  • 864
  • 1
  • 11
  • 25
  • Does this answer your question? [How to match all occurrences of a regex](https://stackoverflow.com/questions/80357/how-to-match-all-occurrences-of-a-regex) – idmean Jul 10 '21 at 09:52

1 Answers1

1

I used the following and it works:

.scan(/\<(.*)\>/).flatten
Rene Chan
  • 864
  • 1
  • 11
  • 25