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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$str =~ s/(.*)\b$match\(\d*\)\s*/\
#but this can leave spaces at the end if name1 is on the last line.