http://www.perlmonks.org?node_id=923977

OlegG has asked for the wisdom of the Perl Monks concerning the following question:

Hi all
I have such text:
{name_b param_v="wh"} {name_a param_x="abc" param_a="fsd" param_y="def"} {name_z param_sd="zka" param_s="df"} {name_a param_y="wtf" param_z="kro" param_c="ptz" param_ch="www"}
And want to get this:
{name_b param_v="wh"} {name_a param_x="abc" param_y="def"} {name_z param_sd="zka" param_s="df"} {name_a param_y="wtf"}
In other words I want to remove all parameters with names different from "param_x" and "param_y" in all tags with name "name_a".
Can this be done with s/// operator without e modifier in one approach?
That's what I think about it:
s/(\{name_a[^}]+?)\w+(?<!param_x|param_y)="[^"]+"/$1/g;
In this way we will remove only first undesirable parameter.
But if we could say to regexp engine:
1. After success substitution return to the position where substitution started and try to substitute again
2. If ok, go to step 1. If nothing matched in this position move along the string as usual and when matched and substituted go to step 1.

In this way work will be done correctly.
Please tell me, is it possible with Perl regexp engine? Or can yo provide me other solution?