|
|
|
|
|
by tierack
6039 days ago
|
|
In that case, /([^@]+)@(.+$)/.match("foo@example.com")[0] returns the whole string matched by the expression, and [1] and [2] return the first and second groups. That's why the throwaway is there. To get rid of the throwaway, this is a possibility: username, domain = */([^@]+)@(.+$)/.match("foo@example.com").captures
Of course, your string better match, otherwise you'll get a NoMethodError. |
|