In the following code:
>>>
$string = "ab";

if ($string =~ /(ab[c$])/)
{
        print "yes: $1\n";
}
>>>

what I'm trying to say is: "match $string IF it contains the letter a,
followed by the letter b, followed by either the letter c or the end of the
string".

But when I run the code, I get the error "/(ab[c5.006)/: unmatched [] in
regexp at test3.pl line 3", because the parser sees "$]" and thinks I want
to interpolate the perl version.

However, if I replace "$" with "\$", the parser thinks I mean, "match
$string if it contains the letter a, followed by the letter b, followed by
either the letter c or a dollar sign", which $string does not match, so the
test fails.

Is there any way to do what I want to do: have an expression in a regexp
that matches either a specific character OR the end-of-string anchor?

        -Bennett

[EMAIL PROTECTED]     http://www.peacefire.org
(425) 649 9024
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to