39

I've got a table in Emacs org-mode, and the contents are regular expressions. I can't seem to figure out how to escape a literal pipe-character (|) that's part of a regex though, so it's interpreted as a table-cell separator. Could someone point me to some help? Thanks.

Update: I'm also looking for escapes for a slash (/), so that it doesn't trigger the start of an italic/emphasis sequence. I experimented with \/ and \// - for example, suppose I want the literal text /foo/ in a table cell. Here are 3 ways of attempting it:

| /foo/ | \/foo/ | \//foo/ |

In LaTeX export, that becomes:

\emph{foo}  &  \/foo/  &  \//foo/

So none of them is the plain /foo/ I'm hoping for.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ken Williams
  • 22,756
  • 10
  • 85
  • 147
  • possible duplicate of [how to insert "|" in org-mode table](http://stackoverflow.com/questions/11876048/how-to-insert-in-org-mode-table) – legoscia Jul 13 '15 at 16:03

3 Answers3

37

\vert for the pipe.

Forward slashes seem to work fine for me unescaped when exporting both to HTML and PDF.

Nils Fagerburg
  • 640
  • 7
  • 12
  • 3
    Great! I'm also using braces for things like `a\vert{}b`, as otherwise it would be `a\vertb` and not work. As found on http://orgmode.org/worg/org-symbols.html . – Ken Williams Mar 04 '11 at 15:06
  • I can't seem to reproduce my weirdness of 2 different exports for slashes (so I edited that out of my question), but I added an example of trying to get literal slashes and not achieving it. – Ken Williams Mar 04 '11 at 15:29
  • But apparently this only affects the exported document, but not how the cell content is interpreted as a string. OP says the pipe character is part of a regexp, and I assumed he/she needs to use this regexp in a formula, say `$4='(if (string-match $1 $2) "Yes" "No")`, but this does not work. – kccqzy Mar 29 '13 at 09:50
  • Like a \vert b.There should be spaces on it's either side. – SuperBear Dec 03 '16 at 12:14
8

Use a broken-bar character, “¦”, Unicode 00A6 BROKEN BAR. This may or may not work for your specific needs, but it’s a good visual approximation.

Sue D. Nymme
  • 838
  • 7
  • 8
0

You could also format the relevant text as verbatim or code:

Text in the code and verbatim string is not processed for Org mode specific syntax; it is exported verbatim.

So you might try something like =foo | bar= (code) or foo ~|~ bar (verbatim). It does change the output format, though.

mzuther
  • 1,158
  • 1
  • 13
  • 24
  • 2
    Doesn't help for tables. My regex `/(foo|bar)/` turns into two table cells, even when surrounded by `~` characters. Have to write it as `/(foo\vert{}bar)/`. Too bad, because I'm using org-mode (in this case) for tracking my development notes, not for exporting to PDF or LaTeX or anything. Oh well. – Sue D. Nymme Jun 03 '15 at 14:43
  • Ooh, but I did just find a (sort-of) solution; will post as an answer. – Sue D. Nymme Jun 03 '15 at 14:53