Try this:
my $string = 'I love c++';
my $compare = 'some compare string';
if ($compare =~ /\Q$string/) { #disables metacharacters until \E
print "$compare contains $string\n";
} else {
print "$compare does not contain $string\n";
}
-----Original Message-----
From: Beau E. Cox [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 8:23 AM
To: [EMAIL PROTECTED]
Subject: Regex problem
Hi All -
This script:
use strict;
use warnings;
my $string = 'I love c++';
my $compare = 'some compare string';
if ($compare =~ /$string/) {
print "$compare contains $string\n";
} else {
print "$compare does not contain $string\n";
}
gives this error:
Nested quantifiers in regex; marked by <-- HERE in m/I love c++ <-- HERE /
at t.pl line 6.
It's the '+'s. I've tried escaping them '\+' but then
the regex matches on '\+'. I don't understand what is
happening.
This is occuring in a script that's manipulating
files; file names with '+'s fail on this error. Is there any
way I can fix this before I fall back to substrings and
'eq'/'ne' compares (ugh).
Aloha => Beau;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]