Possible Duplicate:
Parse email addresses for “from” and “to” fields in Ruby
Given an email address of the form root@host.sub.domain.com, what is the regular expression to get the hostname and the subdomain as two individual variables? I mean $1='host'and $2='sub'?
You help is greatly appreciated 🙂
EDIT I should say I’m asking about a regular expression to do this, no Ruby code. This is to be used in a postfix configuration file, so I need a regexp. I mistakenly talked about Ruby earlier. My fault, sorry for the confusion.
Non-greedy groups are your friend. They match just what you need: