"Richard Lionheart" <NoOne / Nowhere.com> schrieb im Newsbeitrag news:E5CdncY10a8NN3PdRVn-hA / comcast.com... > Hi Robert, > > I originally sent this reply directly to you rather than the group. It's > repeated here in case the first one got lost in your "bit bucket" and to > mention an adaptation for the problem at hand > > > It seems to me quite inefficient to reverse a string > > only to match it with "^". > > > > s.chop! if /\\$/ =~ s > > > > I guess another efficient method is > > > > s.slice!(-1,1) if s[-1] == ?\\ > > Excellent guidance!! In this case, I'll employ the first since it involves > fewer keystrokes, though I expect the second might be a microsecond faster. > > My goal was to chop a final backslash it was immediately preceded by another > backslash. Ok, then my suggestion was not a solution to your problem. > So I'll use: > > s.chop! if /\\\\$/ =~ s Personally I would not use chop! since it is rather meant to remove record separators (similar to chomp! but not as sophisticated, see here: http://www.ruby-doc.org/docs/rdoc/1.9/classes/String.html#M001293 In your case I'd prefer s.sub!( /\\\\\z/, '\\' ) > Again, thanks for your insight! You're welcome. Kind regards robert