Q:

Best way to change "bob@???.???" to "bob@something.com" using Ruby?

What's the best way of doing this:
mail = "bob@something.com"
mail2 = mail.do_magic
# puts mail2 will return "bob@anotherwebsite.com"

I'm thinking regex of course, but is there another cool way? If not, how should I do it using regexp?

A:

Not sure I completely understand what you're asking, but couldn't you use regex like this?
irb(main):001:0> email = "bob@example.com"
=> "bob@example.com"
irb(main):002:0> email.gsub(/@[\w.]+/, '@something.com')
=> "bob@something.com"

Let me know I've missed something or if I'm not understanding the question correctly.

