Q: how do I extract an org-mode link label?

Given an org-mode internal link with the following format:


How do I extract link-label?

I need to process the link as a string, not interactively in an org-mode buffer. I could write a regexp to do this, but am wondering if there's a function already built in.


You want something like this. The regexp you want is already defined in the variable org-bracket-link-regexp.

(let ((s "[[link-target][link-label]]"))
  (string-match org-bracket-link-regexp s)
   (match-string 1 s)
   (match-string 3 s)))

This should return a list of ("link-target" "link-label")


org-copy-visible, bound to C-c C-x v, should do the job for you.

  • Unfortunately, that won't work for my use case, which is to process a string. I've updated the question. – Dan Feb 20 '17 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.