我跑這個代碼沒有問題
<?php
$string='Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\begin{itemnize}
\item first outer
first outer second line
\begin{itemnize}
\item first inner first line with $x^2=y$
first inner second line
\item second inner
\end{itemnize}
\item second out
\end{itemnize}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dol';
//
$newlatex = preg_replace('/\\\\item(([\\s\\S]*)^[^\\\\item]+\\\\(?!\\\\item))/m','<li>$1</li>',$string);
print($string);
print($newlatex);
產生這樣的結果
\begin{itemnize}
<li> first outer
first outer second line
\begin{itemnize}
\item first inner first line with $x^2=y$
first inner second line
\item second inner
\end{itemnize}
\</li>item second out
\end{itemnize}
沒有明顯的錯誤 你能給你的錯誤的詳細信息?
來源
2014-02-23 18:54:15
EdL
在我的本地系統上$ newlatex是一個空字符串。我認爲語法錯了。不管怎樣,謝謝你。 – wieschoo