ssr1012 - 2 years ago 91
Perl Question

# Regex for lookaround to fetch the matched contents

My Code:

#--------------->
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; }  Input Contents: 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


In this case I found single and double entermark before begin{figure} and end{figure}. If the single entermark found before and after the figure then I delete the figure and merge the line with the previous line.

For example figure3 should be deleted and the line should be merged with previous line.

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

Could you please anyone give a path to get the output.

Not sure to well understand your needs, but a simple replace should work:

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";


Output:

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
`
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download