小骆驼 第七章 漫游正则表达式王国
#!/usr/bin/perl
use strict;
use warnings;
$_ = 'ab cde f ghijk10.x12ln';
if(/d/){print "get!
";}
if(/x/){print "get!
";}else{print "no match!
"}
if(/p{space}/){print "get!
";}else{print "no match!
"}
if(/p{Digit}/){print "get!
";}else{print "no match!
"}
if(/p{Digit}p{Hex}/){print "get!
";}else{print "no match!
"}
if(/P{Digit}p{Hex}/){print "get!
";}else{print "no match!
"}
if(/g.i/){print "get!
";}else{print "no match!
"}
if(/./){print "get!
";}else{print "no match!
"}
if(/\/){print "get!
";}else{print "no match!
"}
#get!
#no match!
#get!
#get!
#get!
#get!
#get!
#get!
#get!
$_ = 'aaaabbiaaccdd1122';
if(/(..)1/){print "$1
";}else{print "no match!
"}
if(/(..)1(.)2i1/){print "$1,$2
";}else{print "no match!
"}
if(/(.)1(.)211/){print "$1,$2
";}else{print "no match!
"}
if(/(.)1(.)g{-1}11/){print "$1,$2
";}else{print "no match!
"}
if(/(.)1(.)g{2}11/){print "$1,$2
";}else{print "no match!
"}
#aa
#aa,b
#no match!
#c,d
#c,d
if(/([^ab]+)/){print "$1
";}else{print "no match!
"}
if(/([ab]+)/){print "$1
";}else{print "no match!
"}
if(/([^dD]+)/){print "$1
";}else{print "no match!
"}
#i
#aaaabb
#no match!