in reply to Match a pattern only if it is not within another pattern

Thanks to all the talented monks you have contributed their wisdom on this problem. I learned a lot from this discussion. I want to explain where/how this problem stemmed from --

As far as I understand, I can use regexp to match certain patterns in text. I can also match text that is NOT a certain pattern.

Now, it seems the look ahead|behind negative|positive give me more power over such matches, however, my toolkit is still very pre-natal in that department.

I want to match certain patterns, but if and only if certain other conditions are met. Here is an example. Suppose I am writing a wiki formatting module.

# I want to match all /italics text/ and replace # it with <i>italics text</i> # except, I don't want to match the text in # [http://somewhere.com/foo/bar.html|Somewhere Else] # in other words, I don't want to end up with # [http:<i></i><i>somwhere.com</i><i>foo</i>bar.html...

The above is just a practical application of the general problem that I was facing. So, to summarize, 'foo' 'bar' 'qux' were general placeholders, as BrowserUk correctly guessed, and to some extent, "surrounded by" 'bar' and 'qux' was interchangeable with surrounded by 'qux' and 'bar'. The more general statement would be --

How to match something, but if and only if, certain other condition is met (or condition is not met, which, actually, is no different from 'condition is met'!).

I need to learn a lot about conditional matching.

--

when small people start casting long shadows, it is time to go to bed