Link to home
Start Free TrialLog in
Avatar of rongz
rongz

asked on

pattern writing

hello,
there is a long string,the content is:

 $str="name1(432)\n
       name2(89)\n
       name3(3423)\n
       name1(21)\n";
the problem is I want to delete some name and its value from  $str and only once searching from end(reverse order).
for example:
 if I specify "name1"(its value not given),the result should be:  $str="name1(432)\n
          name2(89)\n
         name3(3423)\n"
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of b2pi
b2pi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
#or
$str =~ s/(.*)\b$match\(\d*\)\s*/\1/s;
#but this can leave spaces at the end if name1 is on the last line.