Looking to replace:
#678# with <span id="note-678"></span>
Try this:
$str = preg_replace('/#(\d+)#/', '<span id="note-$1"></span>', $str);