From: Arlen Cuss Date: 2012-10-16T16:29:14+09:00 Subject: Re: Drop 1st and last particular character Oh, I'm an idiot, the end as well: output = input.gsub(/^#/, "").gsub(/\#$/, "") (escape # to prevent interpolation) On Tuesday, 16 October 2012 at 6:28 PM, Arlen Cuss wrote: > output = input.gsub(/^#/, "") > > > > On Tuesday, 16 October 2012 at 6:27 PM, Иван Бишевац wrote: > > > Simplest method is to use Regex. > > > > 2012/10/16 ajay paswan > > > What is the most efficient way to drop '#' from the first place and last > > > place if any. > > > > > > for example: > > > if input= #hithere# then output = hithere > > > if input = hithere# then output =hithere > > > if input = #hithere then output =hithere > > > if input = hithere then output=hithere > > > > > > -- > > > Posted via http://www.ruby-forum.com/. > > >