Programming language: Ruby 1.9
Problem String: C:/Test/blah.txt to C:/Test/
C:/Test/blah.txt
C:/Test/
I know it\'s an easy question, but Google and the R
More versatile would be the Ruby Pathname class:
require 'pathname' pn = Pathname.new("C:/Test/blah.txt") p pn.dirname.to_s + Pathname::SEPARATOR_LIST
which gives C:/Test/.
Use the Ruby File.dirname method.
File.dirname("C:/Test/blah.txt") # => "C:/Test"