<pre name="code" class="sql">[oracle@june2 perl]$ cat a4.pl
my $a = "abe";
if ($a =~ /a[^d]e/){print "1111111
"};
[oracle@june2 perl]$ perl a4.pl
1111111
[oracle@june2 perl]$ cat a4.pl
my $a = "ade";
if ($a =~ /a[^d]e/){print "1111111
"};
[oracle@june2 perl]$ perl a4.pl
[oracle@june2 perl]$
^表示除其之外的所有字符
[oracle@june2 perl]$ cat a4.pl
my $a = "abe";
if ($a =~ /a[^\]e/){print "1111111
"};
[oracle@june2 perl]$ perl a4.pl
1111111
[oracle@june2 perl]$ cat a4.pl
my $a = "abe";
if ($a =~ /a[^/]e/){print "1111111
"};
[oracle@june2 perl]$ perl a4.pl
1111111
[oracle@june2 perl]$ cat a4.pl
my $a = "a/e";
#if ($a =~ #a[^/]e#){print "1111111
"};
if ($a =~ m#a[^/]e#){print "1111111
"};
[oracle@june2 perl]$ perl a4.pl
[oracle@june2 perl]$
因为使用非 / 字符作为分隔符,m 不能省略。