StackOverflow uses Markdown to convert the syntax you reference (and much more!) To HTML markup. It would be wise for you to use this infrastructure, or, for example, one like this, and not turn it off yourself - why go to all these efforts to reproduce something that works well?
Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-use text format, and then convert it to structurally correct XHTML (or HTML).
If you decide to knock over your own, use something other than regular expressions, like
source
share