The one problem you'll have is that the call to preg_quote() will escape the asterisk character. Given that, your str_replace() will replace the *, but not the escape character in front of it.
Therefore you should change the str_replace('*' ..) with str_replace('\*'..)