You probably want to add something like this:
("l" "Insert a link with a cleaned-up description" entry (file "~/Dropbox/inbox.txt")
"* [[%c][%(replace-regexp-in-string \"^https?://\" \"\" (replace-regexp-in-string \"\\.[a-z0-9]+$\" \"\" \"%c\"))]]"
:prepend t)
This removes both the protocol and the extension. However, while that should work via just one regex, for some reason org-capture's processing hiccups when it sees a pipe in the regex, and doesn't perform the replacement. So instead I have to call replace-regexp-in-string
twice.
Note that all those backslashes are necessary, including the double one.
Also, removing extensions can be messy: considering that the web doesn't impose any requirements for extensions to be there, people are free to use all kinds of addresses, including ones with a dot and some word at the end. E.g. Wikipedia's page of https://en.wikipedia.org/wiki/.com. These will be stripped from the description by the brute approach. Perhaps you'll want to remove just some known extensions—for that, replace [a-z0-9]+
in the second regex with something like \(html\|php\|cfm\)
etc. Again, the backslashes need to be there. To switch off the removal of extensions altogether, replace the second (replace-regexp-in-string ...)
with just \"%c\"
.
%(EXP)
(Evaluate Elisp expression EXP and replace it with the result.) to get the style you want. see orgmode.org/manual/Template-expansion.html#Template-expansion