in reply to Re: Regular Expression Question
in thread Regular Expression Question

That seems like it would work, however, It will still not match the pattern. The regex doesn't seem to be working correctly using the code above. And I believe you need quotes around my $regex = "qr/$string/"; Like so. Lets say you have this:
my $regex = "/[aeiou][aeiou]/";
It tries to match the literal slash then bracket and so on..., not using it as a reg. ex. at all. I think it is taking the pattern to match literally, as in it is trying to match. If you leave off the quotes and you print the string, it isn't right.

Replies are listed 'Best First'.
Re: Re: Re: Regular Expression Question
by perlguy (Deacon) on Apr 04, 2003 at 15:24 UTC

    qr// is its own operator, and will not work with double quotes around it. If your regex variable ($string, in this case) that you will be pre-compiling has slashes in it, then of course it will try to match the slashes. It is assumed that the only thing inside the qr// operator is the regular expression itself. The previous posts before mine didn't contain slashes in their variable, either.

      Thank you perlguy for all your help!! I got it to work now. And again, thanks for the prompt attention!
      P0werz