Perl 正则表达式来提取属性
我正在尝试从文件中获取子字符串。但我只能获取一个子字符串,但无法获取第二个子字符串 以下是一行示例:Perl 正则表达式来提取属性,perl,Perl,我正在尝试从文件中获取子字符串。但我只能获取一个子字符串,但无法获取第二个子字符串 以下是一行示例: <testPoolResult name="Pool" loop="1" currency="false" randomized="false" startTime="01.01.70_02:10:059""01.01.70_02:11:000" duration="0"> <testCase name="Test" status="SUCCESS" iteration="1
<testPoolResult name="Pool" loop="1" currency="false" randomized="false" startTime="01.01.70_02:10:059""01.01.70_02:11:000" duration="0">
<testCase name="Test" status="SUCCESS" iteration="1" startTime="01.01.70_02:10:059" endTime="01.01.70_02:10:059" duration="0">
<testAction name="pend" status="SUCCESS" iteration="1" startTime="01.01.70_02:10:059" endTime="01.01.70_02:10:059" duration="0"/>
有人能帮我吗 替换此行:
if($line =~ /testCase\s+name[=""](.+?)\s+status[=""](.+?)/x)
与
您正在处理XML文件吗?使用适当的解析器,例如:
如果您正在解析XML,请使用XML解析器,例如XML::Twig its bit-rough-way
If($line=~/testCase\s+name\=\“(.*?\”)“\s+status\=\”(.*?\”/i){print$1,$2;}
if($line =~ /testCase\s+name[=""](.+?)\s+status[=""](.+?)/x)
if ($line =~ /testCase\s+name="(.+?)"\s+status="(.+?)"/x)
open test.xml ;
for //testCase echo @name @status ;