I have a file that contains a somehow bad translation of PHP code to TWIG, I need to remove only the first and last occurence of parenthesis () and any occurence of $ that is enclosed between {% and %} tags
For example if in the file there is:
{% if($var.has($something)) %}
This symbols ($($)$) won't be deleted becoase they aren't between {% and %}
I need that get transformed into:
{% if var.has( something) %}
This symbols ($($)$) won't be deleted becoase they aren't between {% and %}
Any ideas of how to do this?
How accurate do you need it? If you don’t have multiple {% %} {% %} on a single line (or if you can
s/%}/&\n/gto prevent that), you could use the horrifyingly uglyIt removes all
$s inside{% %}, and then the outermost parenthesis if any.