Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 正则表达式来提取属性_Perl - Fatal编程技术网

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 ;