I would like to include some examples of regular expressions in an org-mode file. I would like to write ~[[:whitespace:]]~.

However, [[:whitespace:]] is interpreted as a footnote/link, regardless of the syntax:




I've also tried escaping the brackets \[\[:whitespace:\]\] but that just shows the \ in my org-mode buffer.

How can I write [[:whitespace:]] in inline code?

  • Note that this is just a display problem in the org buffer. E.g. html export does not create a link for ~[[:whitespace]]~. Aug 11, 2017 at 9:28

2 Answers 2


You can insert a zero width space between the first two brackets to avoid triggering link detection.

You would type: ~[, then C-x 8 RET ZERO WIDTH SPACE RET, and then continue with the second bracket [:whitespace:]]~.


  1. This is a hack.
  2. Copying and pasting to a terminal will carry the invisible space, so it won't work for testing the examples.

Note: I once saw this hack being used for passwords, so that you had to copy paste the password, and re-typing it would not work. Arghhh! Discovered this via hex dump.

  • Yep, that certainly works! Anyone copy-pasting examples from the HTML export would be rather surprised to find that the data they'd copied doesn't behave as expected though. Aug 8, 2017 at 15:07

Edit: Turns out, this answer does not solve the problem. I had been playing around with M-x org-toggle-link-display and had left it on literal display, which made me think that the brackets were displaying correctly.

So, if turning off the descriptive display of all links is not acceptable, then the only solution I found is a normal source or example block. For example:


But that has the disadvantage that it displays as a block, rather than inline.

Original answer (which does not work):

I think the best solution is to use an inline source block:

An example regular expression is src_lisp{[[:whitespace:]]}

See the manual page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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