in reply to Re: Re: Re: Do nothing? or Do something important in a very obscure way?
in thread Do nothing? or Do something important in a very obscure way?

Skipping over the notion that I can't actually see why anyone would write "Oh here's an x, just ignore it!" unless there is some way to have n in x<n> (x{n}) supplied by a variable such that it read ignore this if n==0, having demonstrated my lack of expertise with regexes, I'm prepared to accept that the construction may have uses I am unaware of.

Thankyou, it's been an educaton.

I look forward to Perl6 Grammers and Rules with relish.


What's this about a "crooked mitre"? I'm good at woodwork!
  • Comment on Re: Re: Re: Re: Do nothing? or Do something important in a very obscure way?

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Do nothing? or Do something important in a very obscure way?
by TheDamian (Vicar) on Aug 23, 2002 at 20:33 UTC
    ...unless there is some way to have n in x<n> (x{n}) supplied by a variable...

    There is. And it's probably exactly what you would have expected: x<$n>

Re^5: Do nothing? or Do something important in a very obscure way?
by Aristotle (Chancellor) on Aug 23, 2002 at 19:10 UTC
    Actually, what x{0} says is "succeed if there are zero x'es here". And that's always true, because we can always match none of something, even in an empty string. So basically, x{0} is a NOP, and so is x??: and x*?:.

    Makeshifts last the longest.

      Actually, that's exactly what I thought it meant, hence the "Do nothing?" in the title.

      I remember the days when I used to be obliged to put blocks of NOP's into my assembler subroutines (we used a ratio of 1::20 active instructions) to allow space for remedial patching of the executable, but I couldn't see why you would add them to a regex!


      What's this about a "crooked mitre"? I'm good at woodwork!
        There is no reason to be adding them to a regex. It is simply due to the way the double colon works that postfixing it to a nongreedy match turns the match into a NOP, which is what TheDamian was mentioning in the Exegesis.

        Makeshifts last the longest.