in reply to Re: Beautiful .. operator
in thread Beautiful .. operator

Sorry, my mistake. Original if(/start/ .. (/end/ && !(/start/../end/))) replaced with if(/start/ .. (!(/start/../end/) && /end/)) And description changed to: take everything between /start/ and (/end/ which is not inside other /start/ .. /end/ block)

Replies are listed 'Best First'.
Re^3: Beautiful .. operator
by ikegami (Patriarch) on Oct 28, 2008 at 23:21 UTC

    take everything between /start/ and (/end/ which is not inside other /start/ .. /end/ block)

    That would be

    start b f j end

    but I get

    start b start c d e end f start g h i end j end

    from /start/ .. (!(/start/../end/) && /end/)

      It seems its harder to explain as I thought...

      This is exactly the output I wished: to get everything between outer 'start' and 'end'

        How about:
        take top level /start/ .. /end/ blocks, including nested /start/ .. /end/ blocks
        Well, that looks like the intention anyway. Intersting stuff.

        It's unfortunate that the level of nesting needs to be known in advance. The solution would be to replace the use of the binary flip-flop operator with the numeric flip-flop operator. Ie the operator that pre-increments every time its left hand operand is true, and post-decrements every time its right hand operand is true, stays the same otherwise, and returns the result of the calculation.

        For some reason, I can't "remember" how the operator is written. Ie what should replace .. to make it numeric, not binary? Any suggestions?

        --
        .sig : File not found.