On Wed Mar 25 2009 @ 3:10, Chas. Owens wrote: > On Wed, Mar 25, 2009 at 13:21, Telemachus <telemac...@arpinum.org> wrote: > snip > > my $string2 = 'remove-all-this (Keep this) remove this too'; > > > > $string2 =~ s/.*\((.*)\)/$1/; > snip > > If $string2 may contain more than one pair of parentheses, you will want to > say > > $string2 =~ s/.*\((.*?)\)/$1/; > > or > > $string2 =~ s/.*\(([^)]*)\)/$1/;
Either I misunderstood the OP's request, or these two are still no good. They don't trim away what follows the closing parenthesis. As I understood the OP, he wanted to remove everything except the info inside of the parens. That is, what he wants left is only 'Keep this'. I think that this would work fine: my $string = 'remove-all-this (Keep this) remove this too'; $string =~ s/.*\((.*?)\).*/$1/; But as you say, if there are multiple instances or nested parens, then this is all the wrong way to go. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/