in reply to need regex help to strip things like embedded C comments

I want to NOT have a two character patern in the middle part.

(?!re).

is for regexps what

[^a]

is for characters. So

(?(?!re).)*

would restrict the presence of the regexp like

[^a]*

would restrict the presence of characters where .* would otherwise be used.

You can combine this trick with the code in the example for (??{...}) in perlre (which handles nested parens).

Replies are listed 'Best First'.
Re^2: need regex help to strip things like embedded C comments
by Eradicatore (Monk) on Jul 22, 2007 at 14:47 UTC
    Thanks all for the "comments". (pun intended). I agree, this code won't compile. I mostly was just curious about the regex part of my question. Suppose I should have used a more "real" example. :)

    I will test out what you said Ik! Thanks!!