How do you replace text surrounded by a custom delimeter with  around it? Overview

I want to have action asterisks in my posts. Basically, asterisks surrounding certain words. Examples: *gasp* or *giggle*

Simple enough. Now I could type that exactly into the editor but it needs to be styled via CSS. This of course calls for span tags.

However, I don't want to have to surround the text with span tags every time. Too tedious. I'll be using this often. 

So, how can I make it so Drupal takes some text and replaces it with span tags surrounding it?

In Other Words...

I want to be able to write simple custom tags around text like:

[=gasp=]


and then have Drupal automatically convert it to: 

&lt;span class="action"&gt;*gasp*&lt;/span&gt;


A Possible Solution?

I've been led to the Custom Filter module and this seems closest to what I want. Now, it's already installed but in trying to add a 'rule', the module asks for the 'Pattern' to look for and the 'Replacement text'.

The problem is I am terrible with regular expressions.

Assuming this module is the right path, can someone tell me what to put in these two forms so the filter works? I have been holding this off for months because I was scared to ask for help.

If the Custom Filter module isn't what I need, what is the solution?

On a sidenote

I don't know what's a good custom tag to use. I came up with [=gasp=] but maybe you can recommend something better? Just as long as its short. I already use Markdown and don't want it to conflict with it.

Either way, thanks for any help in advance.
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;