From: James Edward Gray II Date: 2010-11-04T01:38:59+09:00 Subject: Re: UTF-8 aware chop for 1.8? On Nov 3, 2010, at 11:33 AM, Ammar Ali wrote: > On Wed, Nov 3, 2010 at 5:57 PM, James Edward Gray II > wrote: >> Well, it should be this simple: >> >> str.gsub(/.\z/mu, "") > > On Wed, Nov 3, 2010 at 6:04 PM, Adam Prescott wrote: >>>> s.gsub(/^(.+)./u) { $1 } >> => "one two thre" > > > Beautiful. Thank you both. > > It was a god exercise for me, so I don't necessarily feel that I > wasted 30 minutes of my life :) > > By the way, the m options seems superfluous in James' version. I get > the same results without it. It's not: >> "\n".sub(/.\z/u, "") => "\n" >> "\n".sub(/.\z/mu, "") => "" Using gsub() over sub() was a dumb mistake on my part though. sub() is all you need, since it can only match once. James Edward Gray II