The tramp-file-name-regexp variable is used to match Tramp file names. (edit: see erikriverson's description below for a more convenient way of matching this.)
This is added to file-name-handler-alist (which defines a handler for all file names) and is associated with tramp-file-name-handler , so you can alternatively check the return value of the find-file-name-handler function to see whether it matches. This seems like a slightly more robust method (although in practice it probably doesn't matter).
(eq (find-file-name-handler filename nil) 'tramp-file-name-handler)
(tramp-dissect-file-name filename) will then return the individual components of the connection (also see the variable tramp-file-name-structure ).
phils source share