2014-01-20 177 views
0

我需要一个正则表达式,它将从以下LaTeX方案返回以下字符串数据(粗体)。从LaTeX字符串获取数据的正则表达式

  1. 最后&\end

     
    \begin{pmatrix}?&?\\?&?\\?&1+{\sqrt[3]{x}}\end{pmatrix} 
    
  2. 数据之间的数据​​\end之间

     
    \begin{bmatrix}1+{\sqrt[3]{x}}\end{bmatrix} 
    
  3. 数据\\之间\end

     
    \begin{bmatrix}?\\1+2\end{bmatrix} 
    

鉴于此字符串

 
\begin{pmatrix}?&?\\?&?\\?&1+{\sqrt[3]{x}}\end{pmatrix}\begin{bmatrix}1+{\sqrt[3]{x}}\end{bmatrix}\begin{bmatrix}?\\1+2\end{bmatrix} 

我想匹配这些:

  1. 1+{\sqrt[3]{x}}
  2. 1+{\sqrt[3]{x}}
  3. 1+2
+0

究竟是什么问题?你想获得字符串中每个矩阵的最后(最右边)单元格内容吗?顺便说一句,你为什么删除你尝试的正则表达式? – Palec

回答

0

例1用sed

sed 's/\&\(.*\)\\end{pmatrix}/\1/' 

您应该能够从那里得到休息。

相关问题