From: Sagy Drucker Date: 2012-10-17T16:39:19+09:00 Subject: Re: Drop 1st and last particular character You didn't mention what if you have three times '#'. e.g. input = "#1234#567# I assume you want output = "1234#567" Use the String function "sub" which substitute from the first occurrence only, on the input, Then reverse the input and use it again (to remove last occurrence) e.g.: myString.sub!('#','') myString.reverse!.sub!('#','').reverse! This will keep all the '#' chars in between. Sagy -----Original Message----- From: ajay paswan [mailto:lists@ruby-forum.com] Sent: Tuesday, October 16, 2012 9:06 AM To: ruby-talk ML Subject: Drop 1st and last particular character 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/.