I'm trying to extract information from an email address like so in ruby:
Email: Joe Schmo <[email protected]> to get these three variables:
name = ? email = ? domain = ? I've tried searching everywhere but can't seem to find how to do it correctly. Here's what I have so far:
the_email_line = "Email: Joe Schmo <[email protected]>" name = (/^Email\: (.+) <(.+)>@[A-Z0-9.-]+\.(.+)/).match(the_email_line)[1] email = (/^Email\: (.+) <(.+)>@[A-Z0-9.-]+\.(.+)/).match(the_email_line)[2] domain = (/^Email\: (.+) <(.+)>@[A-Z0-9.-]+\.(.+)/).match(the_email_line)[3] Any idea on how to get those three variables correctly?
.match()to a temporary variable and indexing that.