免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2421 | 回复: 9
打印 上一主题 下一主题

多行匹配查询-求救 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-12-09 11:04 |只看该作者 |倒序浏览
比如“-query 'SELECT
SerialCode, CfmDate, TransDate, TransTime, IndiInstFlag, TransAcntCode, CardNo, CaptAcntCode, FundAcntCode, BusinessCode, ReturnCode, FundCode, AppVol, AppAmnt, CfmVol, CfmAmnt, DiscountRateOfCommission, Commission, AgencyFee, Duty, OtherFee1, NAV, TradingPrice, BookDate, ValidPeriod, BranchCode, PrintCount, SubbranchCode, TACode, BankRemitFlag, CurrencyType,
ManagerID,Rate,FeeAll,VolAmntFlag
FROM
[&"TableName"]”

  怎么匹配查询出这段内容最简单呢?这段是要查询出来的内容,有多行。

  谢谢!

论坛徽章:
0
2 [报告]
发表于 2010-12-09 11:15 |只看该作者
好心人帮帮忙吧!

论坛徽章:
0
3 [报告]
发表于 2010-12-09 11:30 |只看该作者

   
   新手报到都没个好心人帮下吗?哎!

论坛徽章:
0
4 [报告]
发表于 2010-12-09 11:42 |只看该作者
回复 3# langren868

这个 你试试!
    #!/usr/bin/perl -w
while(<DATA>){
if (m#-query \'select#i .. m#\[&\"tablename\"\]#i){
   print;
}
}
__DATA__
hello the world
“-query 'SELECT
SerialCode, CfmDate, TransDate, TransTime, IndiInstFlag, TransAcntCode, CardNo, CaptAcntCode, FundAcntCode, BusinessCode, ReturnCode
, FundCode, AppVol, AppAmnt, CfmVol, CfmAmnt, DiscountRateOfCommission, Commission, AgencyFee, Duty, OtherFee1, NAV, TradingPrice, B
ookDate, ValidPeriod, BranchCode, PrintCount, SubbranchCode, TACode, BankRemitFlag, CurrencyType,
ManagerID,Rate,FeeAll,VolAmntFlag
FROM
[&"TableName"]”
hello the world
hello the world
hello the world
hello the world
hello the world

论坛徽章:
0
5 [报告]
发表于 2010-12-09 11:59 |只看该作者
如果你仅仅为了学习,可以去下个正则匹配器,在里面练熟咯。。。这个不是很难挖。。。

论坛徽章:
0
6 [报告]
发表于 2010-12-09 12:11 |只看该作者
呃,有人回答了。

论坛徽章:
0
7 [报告]
发表于 2010-12-09 12:36 |只看该作者
我试了下:
  
while (my $file1=<DSX>)
{
if (m#-query \'select#i .. m#\[&\"tablename\"\]#i){
   print TEXT "$&";
}

}       
       
但是没看到输出。

论坛徽章:
0
8 [报告]
发表于 2010-12-09 13:05 |只看该作者
回复 7# langren868

$&只是匹配 开头和结尾
试试这个
    #!/usr/bin/perl -w
open F,">text.txt"||die "can't open: $!\n";
select F;
while(<DATA>){
if (m#-query \'select#i .. m#\[&\"tablename\"\]#i){
   print ;
}
}
close F;
select STDOUT;

论坛徽章:
0
9 [报告]
发表于 2010-12-09 13:28 |只看该作者
4楼正解的哇!可以输出啊。。。

论坛徽章:
0
10 [报告]
发表于 2010-12-09 14:40 |只看该作者
回复 8# liyangole


    多谢8楼!
   是能查询出来,可是有多个这样的匹配,匹配出来的就中间多了很多不是这样的数据了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP