Help for this page

Select Code to Download


  1. or download this
    use warnings;
    use strict;
    ...
    my $str3 = "OUT(IN)OUT(IN)OUT(IN)(IN)OUT";
    (my $z = $str3) =~ s/\(.*?\)//g;
    # $z is "OUTOUTOUTOUT"
    
  2. or download this
    use Regexp::Common qw/balanced/;
    
    my $str4 = "a(b(c(d)e)f)g(h(i(j)k)l)m";
    (my $t = $str4) =~ s/$RE{balanced}{-parens=>'()'}//g;
    # $t is "agm"