Given a file name I want to replace the file extension to ".org"
I decided to use replace-regexp-in-string function:
(replace-regexp-in-string "\\(.*\\)\..*$" "\\1.org" "file.conserv.module")
Output:
"file.conserv.modul.org"
I supposed, that it will return "file.conserv.org" like in Perl program:
my $str = 'file.conserv.module';
$str =~ s/(.*)\..*$/$1.org/;
print $str;
How can I get "file.conserv.org"?
This can do what you want without any regular expressions:
(concat (file-name-sans-extension "file.conserv.module") ".org")
If you want to remove the path too:
(concat (file-name-base "file.conserv.module") ".org")
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