On 4/19/05, angie ahl wrote:
The following regex is failing strangely:
my @tables = $content =~ m#\[table\](.*?)\[/table\]#g; foreach (@tables) { my $table = $_; if ($content =~ m#$table#) {print "yes old table is there!\n";} }
@tables contains 2 items (correctly) but seaching for each item in $content does not match.
How can it find 2 matches and then claim that each of them aren't there?
Metachars in the results perhaps? Have you tried dumping @tables using Data::Dumper and looking at the results? Try using quotemeta (http://perldoc.perl.org/functions/quotemeta.html): my $table = quotemeta;
I know that there are metachars in the result. non printing chars that
Meta-characters are not non-printing characters.
I need to leave there until a later part of the processing.
I don't get why this would affect the result though.
Say that you have the string 'ab+c', that is the character 'a' followed by the character 'b' followed by the character '+' followed by the character 'c'. If you use that as a regular expression it says match an 'a' followed by one or more 'b's followed by a 'c' so the regular expression 'ab+c' will match 'abc' or 'abbc' or 'abbbbbc' but it will never match the string 'ab+c'.
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>