fork download
  1. #!/usr/bin/perl
  2. use strict;
  3.  
  4. my $str = '(((
  5. \\begin{align}
  6. \\frac{d_l}{2}< |\\epsilon_H(g(m))| <\\frac{d_r}{2}
  7. \\frac{d_l}{2}< |\\epsilon_H(g(m))| <\\frac{d_r}{2}
  8. \\end{align}
  9. (((';
  10. my $regex = qr/(?:\\begin{align}|\G(?!\A))(?:(?!\\end{align})[^(])*\K\(/p;
  11. my $subst = '\\\\left(';
  12.  
  13. my $result = $str =~ s/$regex/$subst/rg;
  14.  
  15. print "The result of the substitution is' $result\n";
Success #stdin #stdout #stderr 0s 17496KB
stdin
Standard input is empty
stdout
The result of the substitution is' (((
\begin{align}
\frac{d_l}{2}< |\epsilon_H\\left(g\\left(m))| <\frac{d_r}{2} 
\frac{d_l}{2}< |\epsilon_H\\left(g\\left(m))| <\frac{d_r}{2} 
\end{align}
(((
stderr
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?:\\begin{ <-- HERE align}|\G(?!\A))(?:(?!\\end{align})[^(])*\K\(/ at prog.pl line 10.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?:\\begin{align}|\G(?!\A))(?:(?!\\end{ <-- HERE align})[^(])*\K\(/ at prog.pl line 10.