How do you replace text surrounded by a custom delimeter with  around it?
You can use preg_replace as the following in your custom module:

&lt;?php

$string = '[=waves=] words &lt;br/&gt; words &lt;br/&gt; words [=jumps in air &amp; rolls in ground=] &lt;div&gt;words&lt;/div&gt;';
$pattern = '/\[=(.*?)\=]/i';
$replacement = '&lt;span class="action"&gt;*$1*&lt;/span&gt;';
print preg_replace($pattern, $replacement, $string);


which return:

&lt;span class="action"&gt;*waves*&lt;/span&gt; words &lt;br/&gt; words &lt;br/&gt; words &lt;span class="action"&gt;*jumps in air &amp; rolls in ground*&lt;/span&gt; &lt;div&gt;words&lt;/div&gt;