I don't think you can do this by using shortcodes, but of course you can create your own shortcode and put in your own custom PHP.
There are three things you want to do:
- Grab the URL and split it up into an array
- Grab the part of the URL you want from the resulting array
- Explode the variable on the
- and output it in a or multiple variables, which can then be used in your page.
Of course, this only works on the link you mentioned in your post (
.com/name1-to-name2), you can't just randomly throw in some link and expect it to work exactly as with your example. (unless the link is built up 100% the same way)
It's not like a Youtube-link, which is always built up the same way, so you're going to have some work making a functioning shortcode out of this.
Here you can read how to make your own shortcode.