高手们,关于字符匹配的问题!在线等!!!!!!!!!!

zagorot 2003-07-21 10:34:20
小弟我是用perl编网页。
请问如何从my $sql="select tag,id,type,sand from tank where tag=? and id=? and type=? and sand=?";
提取出where 后面的 tag,id,type以及sand????
...全文
40 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
taogx 2003-07-31
  • 打赏
  • 举报
回复
很好
AllCHN 2003-07-21
  • 打赏
  • 举报
回复
if ($sql =~ /where(\s+.*?)$/i) {
($tag, $id, $type, $sand) = &Phrase($1);
}

sub Phrase {
my $context = $_[0];
my ($tag, $id, $type, $sand);
if ($context =~ /\s+tag=(.*?)\s+(and|$)/i) {
$tag = $1;
}
if ($context =~ /\s+type=(.*?)\s+(and|$)/i) {
$type = $1;
}
if ($context =~ /\s+id=(.*?)\s+(and|$)/i) {
$id = $1;
}
if ($context =~ /\s+sand=(.*?)\s+(and|$)/i) {
$sand = $1;
}
return ($tag, $id, $type, $sand);
}

2,203

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧