<p>I have the following string in the smarty (php templating system) variable $test:</p>

<pre><code>&lt;img height="113" width="150" alt="Sunset" src="/test.jpg"/&gt;
</code></pre>

<p>I want to add "em" to the height and width like this:</p>

<pre><code>{$test|replace:'" w':'em" w'|replace:'" a':'em" a'}
</code></pre>

<p>But this doesn't work... What's the problem and the solution?</p>

my regex isn't the greatest, or i'd give you a better matcher, but maybe using what you have through the regex replace would work.
```
```
{$test|regex_replace:'/".w/':'em" w'|regex_replace:'/".a/':'em" a'}
```
```
other matchers to try
```
```
'/\".w/'
'/".*w/'
'/\".*w/'
```
```
i can't play with my smarty sites at the moment, but i'd first remove the " from the replacement value, to see if the bug is there, then remove it from the matcher and just look for height/width.
otherwise i'd do the replace in PHP if you can.