我使用php,我需要用正则表达式拆分字符串(xpath)。 我只需要一个正则表达式来分割下面的“输入”。我希望有一个人可以帮助我。正则表达式拆分xpath
输入: /路径/到/节点/测试
输出:
$result = array(
"path",
"to",
"node",
"test",
);
输入: /路径/到[子= “string”AND sub2 =“string2”]/node/test
输出:
$result = array(
'path',
'to[sub="string" AND sub2="string2"]',
'node',
'test',
);
输入: /路径/到[子/路径/要= “字符串”] /节点/测试
输出:
$result = array(
'path',
'to[sub/path/to="string"]',
'node',
'test',
);
以前谢谢!
问候 萨沙
尝试我的编辑和 –