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

>
>
> 2011/1/18 Kermit Mei <[email protected]>
>
>
>>
>> 在 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*)>/;
>>
>
>
> 因为 \w 只包括 [a-zA-Z0-9_]
>

哦,第二个写错了,应该是这样(或者楼上给出那个[^<>]或许更好一些):
($c) = $s =~ /<\w+\s+(\w+\s*=\s*.+\s*)/;


多谢!

-- 
B.R
Kermit

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

回复