
Quero combinar o ambiente mais interno begin{question}
e seu correspondente end{question}
.
Dados de exemplo
\section{Takayasu arteritis}
\begin{question}
{You get a patient.
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}
\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye.
So special eye diagnosis done.
Affects eye.
\end{question}
Fever of unknown origin can be used when you do not know what is causing the disease.
% Show cases in MedScape and ask class.
Aneurysms.
\subsection{Treatment}
\begin{question}
{What you should always include in Takayasu treatment?
What are the symptoms?}
Blood pressure.
Aneurysms which will burst without treatment.
So blood pressure decreasing drugs like beta blockers along in combination with other drugs.
\end{question}
Minha saída esperada é
\begin{question}
{You get a patient.
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}
ou
\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye.
So special eye diagnosis done.
Affects eye.
\end{question}
ou
\begin{question}
{What you should always include in Takayasu treatment?
What are the symptoms?}
Blood pressure.
Aneurysms which will burst without treatment.
So blood pressure decreasing drugs like beta blockers along in combination with other drugs.
\end{question}
Como você pode combinar apenas o ambiente mais interno?
Responder1
Experimente isto:
pcregrep -M '\\begin{question}(.|\n)*?\\end{question}'
Explicação:
pcregrep
: grep com expressões regulares compatíveis com Perl-M
: permite que os padrões correspondam a mais de uma linha(.|\n)*?
: qualquer caractere normal.
ou nova linha\n
correspondido zero ou mais vezes.
, no modo não ganancioso?
.
Resultado:
\begin{question}
{You get a patient.
What do you notice first in this patient?}
Absence of peripheral pulse.
\end{question}
\begin{question}
{What was the first Takayasu case?}
Young woman in Asia with red vessels in the eye.
So special eye diagnosis done.
Affects eye.
\end{question}
\begin{question}
{What you should always include in Takayasu treatment?
What are the symptoms?}
Blood pressure.
Aneurysms which will burst without treatment.
So blood pressure decreasing drugs like beta blockers along in combination with other drugs.
\end{question}
Responder2
Você precisa que seja uma solução regex pura ou apenas perlish?
perl -lne 'print if(/^\\begin{question}/ .. /^\\end{question}/)' file