Let's say we have one string containg "nethack.cnf". How can I seperate it into two strings? (one containg the filename "nethack" and the other containing the extension, "cnf")

Also, any algorithms that do what I mention above plus remove pathnames would be a plus