The function behaves like the s/pattern/replacepattern/flags in editors as ed/vi or sed. The power of this function lies in replacing variable strings (as opposed to regexplode, where you can explode by regular expression, but not implode...)
string msgin;
/* Checks msgin for the string 'tells you: ' and all following
* characters and encloses those characters by <underline>
* and </underline>. global.
*/
msgin = regreplace(msgin, "tells you: (.*)",
"tells you: <underline>\\1</underline>", 1);
/* replaces all <underline> html tags by the vt100 escape
* sequence for underline.
*/
txt = regreplace(txt, "<underline>", "<ESC>[5m", 1);