拆分独特的正斜杠

时间:2016-10-18 17:33:12

标签: regex perl

Unit: milliseconds
     expr      min       lq     mean   median       uq      max neval
    ntile 608.1126 647.4994 670.3160 686.5103 691.4846 712.4267   100
      cut 369.5391 373.3457 375.0913 374.3107 376.5512 385.8142   100
 dt_ntile 117.5736 119.5802 124.5397 120.5043 124.5902 145.7894   100

尝试拆分字符串,使结果显示为

 ./dms:element[@name="obj_id"]/dms:qualifier[@name="object_status"]/@value[obj_id_status]

有没有办法用正则表达式做到这一点?我希望在./dms:element[@name="obj_id"] dms:qualifier[@name="object_status"] value[obj_id_status] 单独使用时拆分,但不能拆分/并删除./

1 个答案:

答案 0 :(得分:3)

use v5.10;

my $s = './dms:element[@name="obj_id"]/dms:qualifier[@name="object_status"]/@value[obj_id_status]';

my @parts = split qr|(?<!\.)/\@?|, $s;

say for @parts;

输出

./dms:element[@name="obj_id"]
dms:qualifier[@name="object_status"]
value[obj_id_status]