zoukankan      html  css  js  c++  java
  • p{space}|p{Hex}|p{Digit}|转译符|1|g{-1}|[^ab]|/([^dD]+)/

    小骆驼 第七章 漫游正则表达式王国

    #!/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!
    
  • 相关阅读:
    Laravel 框架
    tp5
    jq关于对象类型的判断
    简易的 js 留言板
    学习任务
    实验报告:指针与地址
    C语言数据类型
    嗯,关于 nanxI 的50条~(算是自我介绍吧)
    初学C语言
    dropload.js
  • 原文地址:https://www.cnblogs.com/yuanjingnan/p/11061474.html
Copyright © 2011-2022 走看看