Extracting Filename (without Extension) In Ruby
Join the DZone community and get the full member experience.
Join For Freeโ
Shortest, rock-solid idiom for removing the extension, without
removing the preceding path:
โ
fname.chomp(File.extname(fname))
โ
Best idiom if you are removing the path also:
โ
File.basename(fname, '.*')
โ
Opinions expressed by DZone contributors are their own.
Comments