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 循环">
赞
踩
[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\n"; foreach ($sql =~ /(`\w+`\s*\.*\s*)/g){ print "\$_ is $_\n"; push (@str,$_); }; $sql=""; foreach (@str){ $sql=$sql.$_; }; $sql =~ s/\s+\.\s+/\./g; my @arr=split (/\s+/,$sql); foreach (@arr){ print "\$_ is $_\n"; }; [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` $
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。