From: Ronald Fischer Date: 2007-08-14T19:05:37+09:00 Subject: Exchanging the extension in a filename I have a string representing the name of a java file. I would like to get a new string, where the extension .java has been replaced by .class. My approach was to use String#sub: filename="abc/x.java" filename.sub(/java$/,'class') This works fine, but I wonder whether there isn't a more elegant way to do it. Ronald -- Ronald Fischer Phone: +49-89-452133-162