On Tue, Mar 30, 2010 at 2:18 PM, Robert Klemme
<shortcutter / googlemail.com> wrote:
> 2010/3/30 Jesse B. <jessebos / aol.com>:
>> This second post with the "spaces only" fix seems to meet all the needs
>> of what I was looking for.
>>
>> I love that this got 9 replies in the middle of the night.
>> thanks everyone for your help.
>
> What do you mean, middle of the night? =A0It's quite sunny here and the
> sun isn't even going to settle soon. ;-)
>
> robert
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/

Well, it's also nowhere near the middle of the night here
(n*100 kilometres west of Robert?, where 0 < n < 13?)
but it's definitely not "quite sunny"! In fact, it's raining!
(To quote from "A Song of the Weather"
  by Flanders and Swann - 1950s/1960s sort of English Tom Lehrer's:
  April brings the sweet spring showers.
  On and on for hours and hours.)

How about this? I think it's different from the other solutions(?),
it seems to work, and it doesn't create a string object(?).
  (str =3D~ /[^ ]/) || str.length

def q( str )
  ns =3D str =3D~ /[^ ]/ || str.length  # actual code
  spaces =3D str[/\A */].length # Robert's 2nd post
  str.inspect.ljust(10) + "  #=3D> " + ns.inspect + "  =3D?=3D  " + spaces.=
inspect
end

""          #=3D> 0  =3D?=3D  0
" "         #=3D> 1  =3D?=3D  1
"  "        #=3D> 2  =3D?=3D  2
"c"         #=3D> 0  =3D?=3D  0
" c"        #=3D> 1  =3D?=3D  1
"  c"       #=3D> 2  =3D?=3D  2
" \t cc"    #=3D> 1  =3D?=3D  1