zoukankan      html  css  js  c++  java
  • perl /g

    [oracle@oadb test]$ cat t2.pl 
    my $str='1a2';
    if ($str =~ /[b]*/){print "1111111111
    "};
    [oracle@oadb test]$ cat t2.pl 
    my $str='1a2';
    if ($str =~ /[b]*/){print "1111111111
    "};
    [oracle@oadb test]$ perl t2.pl 
    1111111111
    
    匹配 0 次或多次b
    
    
    
    [oracle@oadb test]$ cat t2.pl 
    my $str='1a2';
    if ($str =~ /[b]?/){print "1111111111
    "};
    [oracle@oadb test]$ perl t2.pl 
    1111111111
    
    匹配 0 次或一次 b字符串
    
    
    
    [oracle@oadb test]$ cat t2.pl 
    my $str='1a';
    if ($str =~ /[b]+/){print "1111111111
    "};
    [oracle@oadb test]$ perl t2.pl 
    [oracle@oadb test]$ 
    
    
    + 匹配 1 次或多次b
    
    
    [oracle@oadb test]$ cat t2.pl 
    my $str='b1a';
    if ($str =~ /[b]+/){print "1111111111
    "};
    [oracle@oadb test]$ perl t2.pl 
    1111111111
    
    
    [oracle@oadb test]$ cat t1.pl 
    my $sql="where `lc`.`tb`.`xx` = 1 and `tb2` . `id2` = 2 or `id3` > 3 and `id4` >22";
     print "$sql is $sql
    ";
     foreach  ($sql =~ /(`w+`s*.?s*)/g){
        print "$_ is $_
    ";
        push (@str,$_);
        };
       $sql="";
       foreach (@str){
         $sql=$sql.$_;
        };
       $sql =~ s/s+.s+/./g;
       my @arr=split (/s+/,$sql);
       foreach (@arr){
        print "$_ is $_
    ";
       };
    [oracle@oadb test]$ perl t1.pl 
    $sql is where `lc`.`tb`.`xx` = 1 and `tb2` . `id2` = 2 or `id3` > 3 and `id4` >22
    $_ is `lc`.
    $_ is `tb`.
    $_ is `xx` 
    $_ is `tb2` . 
    $_ is `id2` 
    $_ is `id3` 
    $_ is `id4` 
    $_ is `lc`.`tb`.`xx`
    $_ is `tb2`.`id2`
    $_ is `id3`
    $_ is `id4
    
    /g模式匹配修饰符查找所有可能的匹配

  • 相关阅读:
    雪花算法 适用于ID 自增
    SB ,mybatis generator 插件 实现 更新操作
    spark优化
    Hive的导入导出方式汇总
    推荐系统架构图
    DBScan算法
    机器学习-逻辑回归算法
    机器学习-微博精准营销
    机器学习-TF-IDF算法
    机器学习-KNN识别手写数字
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349958.html
Copyright © 2011-2022 走看看