的出現次數的直線比方說,我有一個Perl的字符串變量SQL查詢:拆分基於字符串
select a from table one union select b from table two union select c from table three union select d from table four union select e from table five union select f from table six union select g from table seven union select h from table eight
在上面的文字我有一個工會分隔八個單獨的查詢。
我希望其中一半存儲在一個變量中,另一半存儲在另一個變量中。
我知道應該有八個查詢所有的時間和7個工會之間。 我試了下面的腳本,但是不工作。
#!/usr/bin/perl
use strict;
use warnings;
my $var="select a from table one union select b from table two union select c from table three union select d from table four union select e from table five union select f from table six union select g from table seven union select h from table eight";
$var=~m/(.*union{3})(.*)/g;
print $1;
第一場比賽$ 1是確定..但第二場比賽是不正確的。 – user1939168 2013-03-18 13:57:04
@ user1939168:澄清了答案。 – creinig 2013-03-18 14:09:25