From: "Jesús Gabriel y Galán" Date: 2012-09-04T22:52:57+09:00 Subject: Re: how to 2 string from hostname On Tue, Sep 4, 2012 at 3:37 PM, Ferdous ara wrote: > hostname > bd-vs-55.bd.domain.lan > > I just want to convert this so that i can this(capital) > > BD55 > > How can i get that ?? > Thanks for help Which bd are you getting: the first one before the dash or the second one, between the dots? If it's the first one: s = 'bd-vs-55.bd.domain.lan' s.match(/(\w+?)-\w+?-(\d+)/).captures.join.upcase => "BD55" If the second: s = 'bd-vs-55.bd.domain.lan' s.match(/-(\d+)\.(\w+?)\./).captures.reverse.join.upcase => "BD55" Jesus.