perl ^符号

[oracle@june2 perl]$ cat a4.pl 
my $a = "abe";
if ($a =~ /a[^d]e/){print "1111111\n"};

[oracle@june2 perl]$ perl a4.pl 
1111111

[oracle@june2 perl]$ cat a4.pl 
my $a = "ade";
if ($a =~ /a[^d]e/){print "1111111\n"};

[oracle@june2 perl]$ perl a4.pl 
[oracle@june2 perl]$ 

^表示除其之外的所有字符

[oracle@june2 perl]$ cat a4.pl 
my $a = "abe";
if ($a =~ /a[^\\]e/){print "1111111\n"};
[oracle@june2 perl]$ perl a4.pl 
1111111

[oracle@june2 perl]$ cat a4.pl 
my $a = "abe";
if ($a =~ /a[^\/]e/){print "1111111\n"};
[oracle@june2 perl]$ perl a4.pl 
1111111


[oracle@june2 perl]$ cat a4.pl 
my $a = "a/e";
#if ($a =~ #a[^/]e#){print "1111111\n"};
if ($a =~ m#a[^/]e#){print "1111111\n"};
[oracle@june2 perl]$ perl a4.pl 
[oracle@june2 perl]$ 

因为使用非 / 字符作为分隔符,m 不能省略。


 
 

你可能感兴趣的:(Perl高级编程)