Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\begin{table}[position specifier]
\begin{center}
    \begin{tabular}{ c | c }
        \hline
        comand & regex \\ 
        \hline
        HELO & ^\s*HELO\s+(\S+)\s*$ \\
        \hline
    \end{tabular}
    \label{tab:smtp}
\end{center}
\end{table}

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

EDIT:

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
1  
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
add comment

1 Answer

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

\verb!^\s*HELO\s+(\S+)\s*$!
share|improve this answer
1  
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
add comment

Your Answer

 
discard

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.