in reply to Re^2: Regex Problem - alternative searched
in thread Regex Problem - alternative searched

... but as I am a purist in some cases, ...

Sometimes you have to sacrifice purity for practicality, especially in order to circumvent a bug/limitation in other peoples code. I tried to think of an alternative, to your regex, but anything I thought might work was inevitably more complex and therefore likely to exasperate the bug/limitation that is preventing you from using the 'right' solution.

Can Java regex can handle non-capturing grouping and negative lookbehinds?

If so, m[<!--(..(?:(?<!--).)+)-->] might bypass the bug?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^4: Regex Problem - alternative searched
by Skeeve (Parson) on May 18, 2007 at 14:32 UTC

    THANKS! A slight modification seems to work: (?s)<!--(.(?<!--))*-->

    At first it appears a bit odd because of the negative lookbehind which looks like an XML Comment start ;-)


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

        I'm astonished you don't know (?s). It's the same as .../s just inside the regex. It makes the . match lineends too in telling the regex to treat the text as a (?s)-ingle line instead of (?m)-ultiple lines.

        search for "imsx-imsx" in perldoc perlre


        s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
        +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e