perl 正则表达式

正则表达式:
$scalarName =~ s/a/b; # substitute the character a for b, and return true if this can happern
$scalarName =~ m/a; # does the scalar $scalarName have an a in it?
$scalarName =~ tr/A-Z/a-z/; # translate all capital letter with lower case ones, and return ture
if this happens
$scalarName !~ s/a/b/; # substitute the character a for b, and return false if this indeed
happens.
$scalarName !~ m/a/; # does the scalar $scalarName match the character a? Return false
if it does.
$scalarName !~ tr/0-9/a-j/; # translate the digits for the letters a thru j, and return false
if this happens.
--------------------------------------------------------------------------------------------------

#!/usr/bin/perl
$mt="abcdeFGhigk";
#匹配
if ($mt =~ m/Fg/i){
   print  "匹配--it is matched ! \n";

}
# 替换
if ($mt=~s/FG/fg/){
   print "替换-- $mt \n";
}
#转换
if ($mt =~ tr/[a-z]/[A-Z]/){
   print "转换--$mt \n";
}  

你可能感兴趣的:(正则表达式)