Daniel Berger
4/7/2006 12:27:00 AM
rtilley wrote:
> Is there a way to normalize pathnames? On Windows, many system calls
> return a windows path that contains back slashes like this:
>
> C:\windows\system32
>
> I'd prefer to have forward slashes since they are easier to work with
> like this:
>
> C:/windows/system32
>
> Windows will accept either slash. What is the best way for Ruby to
> convert to normal slashes?
See String#tr and String#tr!
"C:\\foo\\bar".tr("\\", '/') # C:/foo/bar
Regards,
Dan