On Saturday 15 July 2006 23:05, brandon coleman wrote:
> Austin Ziegler wrote:
> > On 7/15/06, brandon coleman <metrix1978 / gmail.com> wrote:
> >> any suggestions???
> >
> > File.expand_path($0).gsub(%r{/}) { "\\" }
> >
> > -austin
>
> that would give me two c:\\ruby\\ whatever and if I remove a \ it
> still gives me an error...

Are you testing this in irb? You should know
that \ is used as escape character inside of Ruby string
literals. Thus if you want an actual backslash in the string,
you have to escape it with another backslash.
irb prints a ruby string literal to stdout, thus you see a
double backslash for every actual backslash in the string.

Try:
  > puts File.expand_path($0).gsub(%r{/}, "\\")
to see the "real" contents of the resulting string.

BTW: The literal "\" gives an error because the backslash
before the second quote tells Ruby to include the quote
in the string instead of interpreting it as string delimiter.

-- 
Stefan