# catchfilebetweentags bug with \verb command

With example

\RequirePackage{filecontents}
\begin{filecontents*}{main.tex}
%<*example>
\verb|This is an example|
%</example>
\end{filecontents*}
\documentclass{article}
\usepackage{catchfilebetweentags}
\CatchFileBetweenTags{\test}{main.tex}{example}
\begin{document}
\test
\end{document}


I get output:

! LaTeX Error: \verb ended by end of line.


Everything else is working properly. If I copy/paste the piece of code directly in the main.tex file it works properly.

• the catch commands take a fragment of the file and pass them as an argument of a macro, it is a documented restriction that \verb doesn't work in the argument of another command, – David Carlisle Oct 2 '14 at 8:16

The \verb command works only if the the argument is not already tokenized. The classical situation this shows up in is that you cannot use \verb in the argument of another command. However, the same problem applies here: to save the input to a macro, the 'caught' information has to be tokenized. That can't work, I'm afraid.