Hi --

On 15/01/2008, Gu stav <gustav / vonsydow.tv> wrote:
> Hi! I'm trying to write a regex that splits up a hostname and returns it
> in a nice array. For example:
>
> "eat.chunky.bacon.com" => regex => ["eat","chunky","bacon","com"]
>
> Been trying to wrap my head around this, but I merely get around to
> catching the top domain ;) Anyone done this recently?

Why a regexp?

>> "eat.chunky.bacon.com".split(/\./)
=> ["eat", "chunky", "bacon", "com"]

The above will fail for foo.co.uk, but that's your problem.  :)

-- Thomas Adam