【发布时间】:2014-03-13 16:13:59
【问题描述】:
我想解析 .tex 文件的以下部分
\section{a}
some random lines with lot
of special characters
\subsection{aa}
somehthing here too
\section{b}
我想要\section{a} 和\section{b} 中的内容,所以我在python 中尝试了以下代码
import re
a="my tex string mentioned above"
b=re.findall(r'\\section{a}.*\\section{b}',a)
print(b)
但我得到了b=[]。我哪里错了?
【问题讨论】:
标签: python regex python-3.x