I have a problem with regex that I can't seem to find out what is. I am trying to extract everything between a \begin{spm} tag and a \end{spm} in a tex-document, using preg_match_all(). The regex that I have used (and verified at a regex-checker) is:
[text]\\begin{spm}(.*)\\end{spm}[/text]
Using php, the code would be:
Code: Select all
$texfil = file_get_contents("test.tex");
preg_match_all('/\\begin{spm}(.*)\\end{spm}/',$texfil,$matches);
echo "<pre>".print_r($matches,true);[text]\begin{spm}
\section{A question}
\subsection{Thats why:}
\paragraph{En av de fire musketeer er slik.}
\paragraph{En venn av Moses}
\end{spm}[/text]
Does anyone have any suggestions to why the $matches array returns nothing when running this regex?