From: Robert Klemme Date: 2010-03-30T18:55:36+09:00 Subject: Re: return number of spaces at the beginning of a line 2010/3/30 Josh Cheek : > On Mon, Mar 29, 2010 at 8:41 PM, Jesse B. wrote: > Hi, a quick appraisal of the issues with previous solutions. > Each of these count non-space whitespaces (ie " \t hello" would be 3 instead > of 1 ) > s.index(%r{\S}) > > str[/\A\s*/].length > > s =~ /(\s*)/ > $1.length Oh, that's easily fixed: just replace \s with ' ' e.g. s[\A */].length (still my favorite). I thought general whitespace was sought after. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/