I'm trying to replace all "
" in twig syntax when it's surrounded by "{%
" and "%}
" or "{{
" and "}}
".
For example in the following string :
<p>{{ myFunction() }}</p>
<p> </p>
<p>{{ number|number_format(2, " . ", ' , ') }}</p>
<p>{% set myVariable = ' ' %}</p>
I want to replace every "
" by "" except the "
<p> </p>
" one.
I'm doing the following :
$content = preg_replace('/({[{%].*)( )(.*[}%]})/', '$1 $3', $content);
but it replace only one occurrence of " 
" in each brackets surroundings.
How to make it for all?