Say I have a filename (a list of characters):
"myfile.xml"
How can I get:
"myfile"
?
In case you want to eliminate the extension, I propose to use a library like System.FilePath.Posix
:
import System.FilePath.Posix(takeBaseName)
Then you can use the takeBaseName
function to obtain the basename of a filename:
Prelude> import System.FilePath.Posix(takeBaseName)
Prelude System.FilePath.Posix> takeBaseName "myfile.xml"
"myfile"
This solution works better, since it will also work on "file.gz"
and "foo.7z"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With