【发布时间】:2017-07-26 12:12:29
【问题描述】:
我有这个文件,其中包含几个 math 标记,如下所示:
<Math
<Unique 262963>
<BRect 1.02176" 0.09096" 1.86024" 0.40658">
<MathFullForm `equal[therefore[char[tau]],plus[indexes[0,1,char[tau],char[c]],minus[times[indexes[
0,1,char[tau],char[s]],string[" and "],over[times[char[d],char[omega]],times[char[
d],char[t]]]]]],over[char[tau],char[I]]]'
> # end of MathFullForm
<MathLineBreak 138.88883">
<MathOrigin 1.95188" 0.32125">
<MathAlignment Center>
<MathSize MathMedium>
> # end of Math
就像这样:
<Math
<Unique 87795>
<Separation 0>
<ObColor `Black'>
<RunaroundGap 0.0 pt>
<BRect 0.01389" 0.01389" 0.17519" 0.22013">
<MathFullForm `indexes[0,1,char[m,0,0,1,0,0],char[i]]'
> # end of MathFullForm
我想提取Unique标签和MathFullForm标签的内容,但是我不知道该怎么做。请注意,Unique 标记存在于文件中的其他位置,在 Math 标记之外。
我尝试过使用正则表达式,但效果不太好,并且遗漏了许多标签。然后我考虑使用 XML 解析器,但是因为代码不是有效的 XML,所以这行不通。
谁能引导我在 Python 中朝着正确的方向前进(可以接受正则表达式解决方案)。
【问题讨论】:
-
您的类似 XML 的格式是可理解的标准吗?我以前没有遇到过。
-
@chocksaway 适用于 Adobe Framemaker:help.adobe.com/en_US/framemaker/mifreference/mifref.pdf
-
优秀 - 所以是标准格式。