From: sto.mar@... Date: 2012-10-18T08:08:48+09:00 Subject: Re: Drop 1st and last particular character Am 17.10.2012 09:39, schrieb Sagy Drucker: > 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. this does not work if there is no '#' 1.9.3p194 :001 > myString = '123' => "123" 1.9.3p194 :0ß2 > myString.reverse!.sub!('#','').reverse! NoMethodError: undefined method `reverse!' for nil:NilClass --