【发布时间】:2014-05-15 08:43:32
【问题描述】:
我有一个长文本文件,例如:
COMPONENT;SCALAR;VALUE
point1/point2 - Value Value Value
point1/point2 - Value Value Value
point1/point2 - Value Value Value
point1/point2 - Value Value Value
point1/point2 - Value Value Value
point1/point2 - Value Value Value
point1/point2 - Value Value Value
COMPONENT;SCALAR;VALUE
point3/point4 - Value Value Value
point3/point4 - Value Value Value
point3/point4 - Value Value Value
point3/point4 - Value Value Value
point3/point4 - Value Value Value
point3/point4 - Value Value Value
point3/point4 - Value Value Value
现在我已经提取了 'point3/point4' 类型值的所有唯一值 .. 现在我要做的是提取整个数据块 .. 例如 From COMPONENT;SCALAR ----> \n \n (在块的末尾有两个新行)。现在我想做的是
string =~ /(COMPO\S\spoint1\/point2)(.+?)(COMP)/s;
print $2;
但它不起作用。匹配应该只匹配到第一个 '\n\n' 并且不要贪婪地捕获最大值。任何一个班轮将不胜感激。
【问题讨论】: