TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to print a regular expression in table's column. For example:

\begin{table}[position specifier]
    \begin{tabular}{ c | c }
        comand & regex \\ 
        HELO & ^\s*HELO\s+(\S+)\s*$ \\

But, I have a lot of errors due to ^\s*HELO\s+(\S+)\s*$. So, what does the simplest way to escape this regex?


I do not have enough reputation to ask to my own question. So the most suitable solution is to use \verb comand.

share|improve this question
I've found a good solution for my problem stackoverflow.com/a/2528843/1160443. Do you know any others? – Tural Gurbanov Feb 5 '13 at 10:21
Welcome to TeX.sx! Please provide a Minimal Working Example (MWE) that clearly shows your problem. This should start with \documentclass and end with \end{document}. – Peter Jansson Feb 5 '13 at 10:23
The solution offered on stackoverflow is the most natural one, in my opinion. If it suits you perfectly, you should post your end-command in an answer to that question, with a word of explanation. If you have any problem with it (even if it is syntax clumsiness), you should edit your question with that suggestion and an explanation about why you are looking for something else. – T. Verron Feb 5 '13 at 10:25
Thanks, I've edit the question. – Tural Gurbanov Feb 5 '13 at 10:32
Oh, right, the reputation issue. I've added this answer as community wiki then. – T. Verron Feb 5 '13 at 10:51

From the comments and this question on stackoverflow, a solution is to use \verb, for example this way :

share|improve this answer
If you have many such regular expressions, you can use the shortvrb package to define for instance " to be a shorthand for \verb". Then it would be used as "^\s*HELO\s+(\S+)\s*$". – Bruno Le Floch Feb 5 '13 at 12:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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