Why not store the UBBCode in the database then parse it out when it's called?
Putting a post into the database happens once. Getting it out of the database happens about a three hundred billion gazillion times

I love the new way, it allows for lots of custom ubb code without loosing any performance. And all at the little cost of a little diskspace on your database server.