in reply to Re: •Re: A pattern that matches three consecutive copies...
in thread A pattern that matches three consecutive copies...

Well, fred|barney as a string doesn't have three things that match the regex (fred|barney) in a row. So I would expect it to say "no match". Are you getting something different from that?

-- Randal L. Schwartz, Perl hacker

  • Comment on •Re: Re: •Re: A pattern that matches three consecutive copies...

Replies are listed 'Best First'.
Re: •Re: Re: •Re: A pattern that matches three consecutive copies...
by WarrenBullockIII (Beadle) on Jun 09, 2002 at 16:03 UTC
    Yes actually I am getting it to say no match. Thats what I expect it get too! So I guess I don't uderstand the question in the book then...
      Three consecutive copies of the regex fred|barney would be like:
      fredfredfred fredbarneyfred barneybarneybarney
      and so on. Put one of those as your string on the left of the =~ operator, and it'll match!

      -- Randal L. Schwartz, Perl hacker

        ok well the way I understood the question was totally oposite of that... sorry:-) So the point to question 1 in chapter nine is that you can use the contents of a variable as the pattern instead of typing out an actual pattern? so for example:
        barneybarneybarney =~ /($what){3}/
        would match the string because the variable contains the contents of the string barneybarneybarney ??? Sorry if I'm being a pain in the neck but I just want to make sure I fully understand this before I move on to chapter 10.