Gum*_*mbo 6

试试这个:

$str = preg_replace('/#(\d+)#/', '<span id="note-$1"></span>', $str);
Run Code Online (Sandbox Code Playgroud)