in reply to Re: More Variable length regex issues
in thread More Variable length regex issues

The reason for your bug (in your Note:) is because when Perl is FIRST parsing your code, and it tries to determine where your regex starts and ends, it only looks for balanced square brackets. At that stage, it's not actually parsing your regex, just looking for its start and end. Thus, the square brackets IN the regex that aren't backslashed throw the parser off.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

  • Comment on Re: Re: More Variable length regex issues

Replies are listed 'Best First'.
Re: Re: Re: More Variable length regex issues
by BrowserUk (Patriarch) on Jun 10, 2003 at 17:31 UTC

    Thanks for that. So the answer is, don't use square brackets as delimiters if the regex contains (unbalanced) square brackets.

    It's a shame that there aren't a couple more sets of balanced brackets in the arsenal:) Preferably a pair that could be used soley for quote-like delimiting. Maybe now we have unicode, we could find a pairing that wouldn't get overloaded for 7 other things too? Some chance I think:)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


      Well, there are the French/German style quotes that look like << and >>... but Perl 6 uses them (believe it or not!).

      You can't use anything other than paren, bracket, brace, or angle-bracket in Perl right now to balance, since they're hardcoded into the parser/tokenizer. But you could certainly choose some obscure unicode character that doesn't need balancing. Actually, if you could tell the parser to include a pair of your own, like ` and ', that'd be cool.

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;