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.
Trending
-
DZone's Article Submission Guidelines
-
Is Podman a Drop-In Replacement for Docker?
-
Effective Java Collection Framework: Best Practices and Tips
-
Microservices With Apache Camel and Quarkus
Comments