正则表达式用于获取匹配内容的外观

时间:2017-08-16 10:30:11

标签: perl

我的代码:

#--------------->
sub FigureMoves
#--------------->
{
    my $FigMove = shift;

    my ($fpre,$fmatchs,$fposts) = "";
    while($FigMove=~m/(\S)\s?\\begin\{(figure\d+)\}((?:(?!\\end\{\2\}).)*)\\end\{\2\}\s?(\S)/gs)
    {
        $fpre = $fpre.$`; $fmatchs = $&; $fposts = $';

        print "$fmatchs\n";

        $fpre = $fpre.$fmatchs; $FigMove = $fposts;
    }
    if(length $fpre) {  $FigMove = $fpre.$fposts;  }

    return $FigMove;
}

输入内容:

r_{2}, T)$ for any $ T>0  $. This fact is verified by the numerical
simulation in Figure 1.

\begin{figure1}
  % Requires \usepackage{graphicx}
  \center
  \includegraphics[width=14cm]{liu1727.eps}\\
  \caption{Numerical solutions $x(t)=(x_1(t),x_2(t))^T$ of systems (3.1) for  initial value $(1.2,-1.3)^T, (0.3,-0.4)^T$. }
\end{figure1}

From (3.2), we can choose $\sigma=0.01$ such that $(2.15)$ holds.

stability for FCNNs with   proportional delays and oscillating
leakage coefficients.  In particular, such topic has not been
\begin{figure3}
  % Requires \usepackage{graphicx}2
  \center
  \includegraphics[width=14cm]{liu2727.eps}\\
  \caption{Synchronous errors of system (3.1) $x(t)-x^*(t)=(x_1(t)-x_1^*(t),x_2(t)-x_2^*(t))^T$  with  initial value $(2,-3)^T, (-7,6)^T, (4,-5)^T$. }
\end{figure3}
touched in most recently references [28--33] on FCNNs.
 Thus, all the results in these literature and the references

在这种情况下,我在开始{figure} end {figure} 之前找到了单输入和双输入标记。如果在数字之前和之后找到单个商标,那么我删除数字并将该行与前一行合并。

  

例如,应该删除figure3,并且该行应该与前一行合并。

     具有比例延迟和振荡的FCNN的稳定性   泄漏系数。特别是,在FCNN最近的参考文献[28--33]中,这个话题还没有被强烈地触及。    因此,这些文献中的所有结果和参考文献

你能不能给任何人提供一条获得输出的途径。

1 个答案:

答案 0 :(得分:1)

不确定是否能很好地理解您的需求,但简单的替换应该有效:

my $FigMove = <<'EOD';
r_{2}, T)$ for any $ T>0  $. This fact is verified by the numerical
simulation in Figure 1.

\begin{figure1}
  % Requires \usepackage{graphicx}
  \center
  \includegraphics[width=14cm]{liu1727.eps}\\
  \caption{Numerical solutions $x(t)=(x_1(t),x_2(t))^T$ of systems (3.1) for  initial value $(1.2,-1.3)^T, (0.3,-0.4)^T$. }
\end{figure1}

From (3.2), we can choose $\sigma=0.01$ such that $(2.15)$ holds.

stability for FCNNs with   proportional delays and oscillating
leakage coefficients.  In particular, such topic has not been
\begin{figure3}
  % Requires \usepackage{graphicx}2
  \center
  \includegraphics[width=14cm]{liu2727.eps}\\
  \caption{Synchronous errors of system (3.1) $x(t)-x^*(t)=(x_1(t)-x_1^*(t),x_2(t)-x_2^*(t))^T$  with  initial value $(2,-3)^T, (-7,6)^T, (4,-5)^T$. }
\end{figure3}
touched in most recently references [28--33] on FCNNs.
 Thus, all the results in these literature and the references
EOD


$FigMove =~ s/(?<!\n)\n\\begin\{(figure\d+)\}((?:(?!\\end\{\1\}).)*)\\end\{\1\}\n(?!\n)//gs;
print $FigMove,"\n";

<强>输出:

r_{2}, T)$ for any $ T>0  $. This fact is verified by the numerical
simulation in Figure 1.

\begin{figure1}
  % Requires \usepackage{graphicx}
  \center
  \includegraphics[width=14cm]{liu1727.eps}\\
  \caption{Numerical solutions $x(t)=(x_1(t),x_2(t))^T$ of systems (3.1) for  initial value $(1.2,-1.3)^T, (0.3,-0.4)^T$. }
\end{figure1}

From (3.2), we can choose $\sigma=0.01$ such that $(2.15)$ holds.

stability for FCNNs with   proportional delays and oscillating
leakage coefficients.  In particular, such topic has not beentouched in most recently references [28--33] on FCNNs.
 Thus, all the results in these literature and the references