I'm outputting some HTML from a database to a page, containing constructions like this:

```
<p>Department: *|accounting|*</p>

```

I would like to find and replace all text wrapped with *| and |* and use the word in between as a variable for my translate function.

I've found a [partial answer](https://stackoverflow.com/questions/5326692/regular-expression-find-elements-wrapped-with-specific-selectors). Could you guys help me out with the rest? Thanks.

This is somewhat what I'm looking for...

```
$html_from_database = "<p>Department: *|accounting|*</p>";

$updated_html = preg_replace("*|(.*?)|*", translate('accounting'),$html_from_database);

```

Is something like this possible? What about the regex? Is it not too resource intensive or to greedy? Please note that the only characters between *| and |* will be a-z A-Z -\_ 0-9.

Thanks in advance.