• perl + 匹配前导模式一次或者多次


    Vsftp:/data01/mysqllog/binlog# cat a2.pl
    $_="aaaa@[2]sasas";
    if ($_ =~/.*?(@[[0-9]+]).*/){print "$id is $1
    "};
    
    Vsftp:/data01/mysqllog/binlog# perl a2.pl
    $id is @[2]
    
    
    
    Vsftp:/data01/mysqllog/binlog# cat a2.pl
    $_="aaaa@[23]sasas";
    if ($_ =~/.*?(@[[0-9]+]).*/){print "$id is $1
    "};
    
    Vsftp:/data01/mysqllog/binlog# perl a2.pl
    $id is @[23]
    
    d+ 匹配多个数字字符串,和 [0-9]+ 语法一样 
    +匹配前导模式一次或多次
    
    
    [oracle@oadb test]$ cat a3.pl 
    $_="aaaa@[3]sasas";
    if ($_ =~/.*?(@[[0-9]{1,3}]).*/){print "$id is $1
    "};
    
    [oracle@oadb test]$ perl a3.pl 
    $id is @[3]
    
    
    [oracle@oadb test]$ cat a3.pl 
    $_="aaaa@[30]sasas";
    if ($_ =~/.*?(@[[0-9]{1,3}]).*/){print "$id is $1
    "};
    [oracle@oadb test]$ perl a3.pl 
    $id is @[30]
    
    
    [oracle@oadb test]$ cat a3.pl 
    $_="aaaa@[301]sasas";
    if ($_ =~/.*?(@[[0-9]{1,3}]).*/){print "$id is $1
    "};
    
    [oracle@oadb test]$ perl a3.pl 
    $id is @[301]
    
    
    [oracle@oadb test]$ cat a3.pl 
    $_="aaaa@[3012]sasas";
    if ($_ =~/.*?(@[[0-9]{1,3}]).*/){print "$id is $1
    "};
    [oracle@oadb test]$ perl a3.pl 
    [oracle@oadb test]$ 
    
    [0-9]{1,3} 匹配1到3次
    
    {m} 匹配刚好是 m 个 的指定字符串 
    
    {m,n} 匹配在 m个 以上 n个 以下 的指定字符串 
    
    {m,} 匹配 m个 以上 的指定字符串 


    
                                        
    
  • 相关阅读:
    Java基本数据类型的包装类
    Java数据类型基础
    Xscan安装
    Notepad++配置HexEditor插件
    [WP]XCTF-re2-cpp-is-awesome
    [WP]XCTF-tt3441810
    [WP]XCTF-re1-100
    [WP]XCTF-Mysterious
    [WP]xctf-parallel-comparator-200
    [WP]XCTF-elrond32
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349972.html
Copyright © 2020-2023  润新知