2017-08-16 35 views
1

我的代碼:正則表達式環視獲取匹配的內容

#---------------> 
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 

在這種情況下,我發現單,雙entermark 之前開始{圖}結束{figure}。如果在之前和之後找到單個的entermark,那麼我刪除並將該行與上一行合併。

例如figure3應該被刪除,該行應該與前一行合併。

穩定性與比例延遲和振盪 漏光係數FCNNs。尤其是,這樣的話題一直沒有被感動在最近參考文獻[28--33]上FCNNs。 因此,在這些所有的結果文獻和參考文獻

請問任何人都可以給出一個路徑來獲得輸出。

回答

2

不知道很好地瞭解您的需求,但一個簡單的更換應該工作:

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 
+0

謝謝您的回答。 _例如圖3應該被刪除,並且該行應該與前一行合併_ – ssr1012

+0

該情景是合併周圍的數字開始和結束,而有一個單一的輸入。不考慮數字前後的雙重輸入。 – ssr1012

+0

@ ssr1012:看我的編輯。那是你想要的嗎?, – Toto