OlegG has asked for the wisdom of the Perl Monks concerning the following question:
And want to get this:{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"}
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".{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 this way we will remove only first undesirable parameter.s/(\{name_a[^}]+?)\w+(?<!param_x|param_y)="[^"]+"/$1/g;
|
|---|