在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 simple
print "It matches\n" if "hello world" =~ /world/; print "It doesn't match\n" if "hello world" !~ /word/; $_ = "hello world"; print "it matches\n" if m{world}; print "it matches\n" if m!world!; print "it matches\n" if m(world); print "it matches\n" if m[world]; 2 metacharacter
$x = "cat dog house"; # 3 words while ($x =~ /(\w+)/g){ print "Word is $1, ends at position ", pos $x, "\n"; } # reverse all the words in a string $x = "the cat in the hat"; $x =~ s/(\w+)/reverse $1/ge; # $x contains "eht tac ni eht tah" # convert percentage to decimal $x = "A 39% hit rate"; $x =~ s!(\d+)%!$1/100!e; # $x contains "A 0.39 hit rate"
Date: 2011-10-27 22:02:37 HTML generated by org-mode 6.33x in emacs 23 |
请发表评论