in reply to Re: Regex To remove text between parentheses
in thread Regex To remove text between parentheses
Remember that * is *greedy* ... it will match the longest possible substring. So, given a string like
(*) Microsoft Internet Exploder (which calls itself "Mozilla") - a pro +duct of a convicted violator of the Sherman Act (wow)
That greedy quantifier will snatch up that * after the opening paren, and not stop till it gets to the ) that follows the "wow" (that IS the longest substring that matches your RE).
As to the suggestion you use a character class (hint: match one or more things that aren't closing parentheses), see Death to Dot Star! for a discussion of why not to use .*
HTH!
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
|
|---|