I don't know if this is possible, but it should be. However, it doesn't seem to be working for me. Perhaps someone can tell me if and how I can get it to work:
I use 😐|: for my delimiter for str_replace, etc.
When replying, the new PM is appended in front of the existing chain of replies, thus the same table entry is used and updated each time. Problem is in storing the sent date, and providing time zone and format adjustments:
$string='This is the message that was sent on 😐1161850848|:';
$newString=preg_replace('/([0-9]*)/',format_time(adjust_time('${1}')),$string);
// the result of this is as if ${1} = 0
$newString=preg_replace('/([0-9]*)/','${1}',$string);
// returns 'This is the message that was sent on 1161850848';
It seems that using the function prevents accessing the result of the match.