I want to match all text that is encapsulated within <? and ?>. I found a fairly easy way to do this using lookahead:
<\?([^?]|\?(?!>))*\?>
Unfortunately lookahead isn’t supported by the tool I’m writing the regex for. Is there a way around this?
For your specific case, you could simply make the repetition ungreedy:
This will only go until the first
?>. Any single?before that will be covered by the.*, but when the engine encounters the first?>it will stop.Note that (unless you use the
DOTALLmodifier) this will not work for sections going across multiple lines. If you cannot use the modifier, this will do (platform-independently):