I'd like to do a regex_replace where both the search & replace values are stored in variables. (It's a whole lot neater and useful.)
Storing the replace text in a variable works fine, but not the search text. I'm probably just making an ignorant mistake.
The following is the working code from my Entry template.
<mt:Assets> <mt:AssetLabel setVar="my_asset_label" /> <mt:if name="body_content" like="$my_asset_label"> <mt:SetVarBlock name="new_image_block"> <div class="std_side_image_$4" style="width: 150px;"> <img src="$3" width="" height="" alt="[PHOTOGRAPH] $2" title="[PHOTOGRAPH] $2"> <p>$2</p> </div> </mt:SetVarBlock> </mt:if> </mt:Assets><mt:var name="body_content"
regex_replace="/<span class="mt-enclosure .+?><a href="(.+?)"><img alt="(.+?)" src="(.+?)" class="mt-image-(.+?)".+?</span>/g","$new_image_block"
/>
Reported on Movable Type 4.2
Duh, and I should have specified: the following didn't work:
So... how can we put the search pattern into a variable?
thanks.
I repeated my question and got some useful answers in a second post.
The short answer was: probably can't do this in regex_replace but you can use variables (without anything other text) in a simple replace.