3 and `id4` >22";#my $sql='where `lc` = 1 and `tb2` . `id2` = 2 or `id3` > 3 and `id4` >22'; foreach ($sql =~ m/(`\w+`\s*\.?\s*)/g_perl语言 split 循环">
当前位置:   article > 正文

perl 循环截取字符串_perl语言 split 循环

perl语言 split 循环
  1. [oracle@oadb test]$ cat t1.pl
  2. my $sql="where `lc`.`tb`.`xx` = 1 and `tb2` . `id2` = 2 or `id3` > 3 and `id4` >22";
  3. print "\$sql is $sql\n";
  4. foreach ($sql =~ /(`\w+`\s*\.*\s*)/g){
  5. print "\$_ is $_\n";
  6. push (@str,$_);
  7. };
  8. $sql="";
  9. foreach (@str){
  10. $sql=$sql.$_;
  11. };
  12. $sql =~ s/\s+\.\s+/\./g;
  13. my @arr=split (/\s+/,$sql);
  14. foreach (@arr){
  15. print "\$_ is $_\n";
  16. };
  17. [oracle@oadb test]$ perl t1.pl
  18. $sql is where `lc`.`tb`.`xx` = 1 and `tb2` . `id2` = 2 or `id3` > 3 and `id4` >22
  19. $_ is `lc`.
  20. $_ is `tb`.
  21. $_ is `xx`
  22. $_ is `tb2` .
  23. $_ is `id2`
  24. $
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/738383
推荐阅读
相关标签
  

闽ICP备14008679号