On Mar 29, 2010, at 7:41 PM, Jesse B. wrote: > How would I find the number of spaces at the beginning of a line before > the occurrance of the first non-space character? > > Would the best method be to use a regular expression that covers all > non-space characters and get the index of the first occurrance of that? > -- > Posted via http://www.ruby-forum.com/. s = " abc" s.index(%r{\S}) # => 3 s.scan(%r{^\s*}).first.size # => 3 Gennady.