在 2011年1月17日 下午6:25,cnhack TNT <[email protected]>写道:

>
> use Data::Dumper;
>
> $s = q/<button type="button" style = "
> border:none;background:url(button_bk.png); width:150px; height:49px; ">/;
>
> ($c) = $s =~ /<([^<>]+?=[^<>]+?)>/;
>
> 这个可以,但是为什么我写的这个不能匹配:
($c) = $s =~ /<\w+\s*(\w+\s*=\s*\w+\s*)>/;


> $bth{$1} = $2 while $c =~ /\s([\w-]+)\s*=\s*"([^""]+?)"/g;
>
> print Dumper \%bth;
>
>

恩,多谢,修改一下就可以用了(要替换的话不知有没有办法可以不生成那俩变量?):
while ($c =~ /\s([\w-]+)\s*=\s*"([^""]+?)"/g) {
    my $tmp1 = $1;
    my $tmp2 = $2;

    $tmp2 =~ s/\s//g;
    $bth{$tmp1} = $tmp2;
}

<snip>

Thanks
-- 
B.R
Kermit

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复