I was going to suggest a BBCodeParser...
I have also looked into PECL and Pear HTML_BBCodeParser. But i don't want my application to be dependant on extensions
I find that to be very strange. Why reinvent the wheel? One of the principles of good software-engineering is DRY (Don't Repeat Yourself). You're trying to solve a problem that has already been solved.
I like to do things on my own!
That's not bad in of itself, but there are times when you are better off using a tried and true solution; one that is better tested and more robust than your own (as you're finding out). That way you will spend time on the problem you actually want to solve instead of solving a problem that has already been solved. Don't fall into the trap of reinventing the wheel. :)
My suggestion (and solution) to you is to use a BBCode parser.
EDIT
Another thing is that you're parsing something that is HTML-like. Things of that nature don't lend themselves easily to being parsed by regular expressions.