Best solution implementing “basic” bbcode with php [duplicate]

I’m writing a board software which have basic styling such as bold, italic, underline, strikethrough. I use the bbcode syntax for them. For full bbcode support/compatible, I will need regex, but for that basic styling, I found that I can do str_replace with [b] [i] [/close-tag]… replaced with after I do a htmlspecialchars() sanitize. Could there be a problem with that?