Basically if you want to match upon string where one or more characters would mean something to a Perl regex, you need to say that: "I don't want these special characters to count, i.e. mean something in a regex sense" - otherwise when Perl interpolates that string, those characters "will count". There are a couple of ways to say "please use all these characters verbatim", I showed one of these.#!/usr/bin/perl -w use strict; my $str1 = "Hi("; my $str2 = "hi"; if ($str2 =~ /\Q$str1\E/) #\Q...\E means like qr #don't interpret characters #like '(' within $str1 #use them verbatim { print "Match: Yes\n"; } else { print "Match: No\n"; } #prints Match: No $str2 = "hI("; if ($str2 =~ /\Q$str1\E/i) #/i means case insensitive { print "Match: Yes\n"; } else { print "Match: No\n"; } #prints Match: Yes
In reply to Re: Possible Match Problem
by Marshall
in thread Possible Match Problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |