Apply Perl RegExp to Remove Parenthesis and Text at End of String
问题 I have a string which includes parenthesis with text inside the parenthesis. How do I remove the parenthesis with text at the end of the string while keeping the other words in string? Input: Potatoes Rice (Meat) Output: Potatoes Rice My code: #! /usr/bin/perl use v5.10.0; use warnings; my $noparenthesis = "Potatoes Rice (Meat)"; $noparenthesis =~ s/^/$1/gi; say $noparenthesis; 回答1: #! /usr/bin/perl use v5.10.0; use warnings; my $noparenthesis = "Potatoes Rice (Meat)"; $noparenthesis =~ s/\(.