How about:

$STRING = "\\servername\sharename"

? SUBSTR(SUBSTR($STRING,1,INSTRREV($STRING,"\")-1),3)

But you will probably get some other takes on this. Requires the INSTRREV function which was recently added (few releases ago).

-Shawn