Help for this page

Select Code to Download


  1. or download this
    my $str = "1*(2+3)*(3+4)+5*(6+7)";
    $str =~ /(?: \( .+? \) | [^+()] )+ (\+ .*)/x;
    say "Match: $1";
    
  2. or download this
    $str = "1*(2+3)*(7+(3+4)+2)+5*(6+7)";
    $str =~ /( \( (?: [^()]++ | (?1) )* \) | [^+()] )+ (\+ .*)/x;
    say "Match: $2";
    
  3. or download this
     /(                      # Capture group 1
         \(                  # Opening paren
             (?:             # Non-capture group
    ...
      
      (\+ .*)                # Plus sign, and remainder of string
     /x;