Regex help?

Hey all,

I’m in the process of learning Regex, and trying to put together a real-world example… Here’s my problem:

I need to format strings that have phrases like this, and phrases /like this/, where strings surrounded by asterisks would be wrapped with <strong> tags, and strings surrounded by forward-slashes would be wrapped with <em> tags. These strings can contain HTML tags. When formatting the strings, the formatting marks (* and /) should be replaced by their relative tags. Here are my current expressions:


Strong Exp: /\s+[*]+([^*]+)[*]+\s+/i
Em Exp: /\s+[\/]+([^\/]+)[\/]+\s+/i

Obviously, these are not sufficient for my needs… The primary reasons being that I need to:
[LIST=1]
[]Ignore instances where the string begins and/or ends inside of an HTML tag, and
[
]Ignore instances where the formatting marks are part of larger strings where those marks are necessary such as in a URL (http:**//**google.com) or while in a notation (…*****Offer valid only on in-store…)
[/LIST]

An example string:

*know who, http://dude.com .. *that's* right, /bro/!

Where-as the word “that’s” would be bold, and the word “bro” would be italic.

I’m at a loss. Any ideas?

Thanks in advance! :smiley: