Perl解析具有更改的字段大小的多行文件
|
我对此很困惑。我正在尝试解析具有如下数据的文件:
\"1111 Some random descriptive text can have numbers and letters\",
// :property1.Some description
// :property2.A different description
// :property3.Yet another
\"2222 More random text here\",
// :property1.Some description
// :property1.A different description
// :property2.Yet another description
// :property3.Yet another
我将解析它并创建html文件。
我现在做完后在数组中:
@array = <FILE>;
#Put it in a single long string:
$long_string = join(\"\",@array);
#Then trying to split it with the following regex:
@split_array = split(/\\\"\\d{4}.+\",/,$long_string);
我打算以某种方式保存匹配字符串,并以某种方式将其与属性字段相关联...
现在真的很怀疑我的方法。
没有找到相关结果
已邀请:
1 个回复
宠封钞轰
开头,而有些则不是。 行的开头有一定的规律性,而其余的则有很多可变性。 通过将文档放到一个单独的字符串中,可以削弱这些杠杆作用。 另一个关键的解析策略是将事情分解为简单易懂的步骤。同样,在这种情况下,针对一个巨型字符串运行一个正则表达式通常是错误的方向。 这就是我的开始方式: