On Mar 25, 2008, at 3:02 PM, Martin DeMello wrote: > Given: > an outline list, with each line indented by a series of tabs > a list of bullets (assume a circular list, for simplicity) > > Write a function that replaces every tab with two spaces, except for > the last one, which is replaced by a bullet. > > example: > > input file: > foo > \t bar > \t \t baz > \t \t \t hello > \t \t world > > bullets: %w(* - o x) cfp2:~ > cat a.rb DATA.read.gsub(%r/(?:\t\ ?)+/){|s|' '*(n=s.count("\t")-1)+%w(* - o x) [n]+' '}.display __END__ foo bar baz hello world cfp2:~ > ruby a.rb foo * bar - baz o hello - world a @ http://drawohara.com/ -- sleep is the best meditation. h.h. the 14th dalai lama