Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/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
Regex X路径+;正则表达式匹配模式_Regex_Xpath_Query String - Fatal编程技术网

Regex X路径+;正则表达式匹配模式

Regex X路径+;正则表达式匹配模式,regex,xpath,query-string,Regex,Xpath,Query String,鉴于以下情况 <Line> <Supplier>Fuel Surcharge - 36</Supplier> <Supplier>Fuel Surcharge - 35</Supplier> <Supplier>46081 46150 46250 46280 46286</Supplier> <Supplier>Fuel Surcharge - 35451</Su

鉴于以下情况

<Line>
    <Supplier>Fuel Surcharge - 36</Supplier>
    <Supplier>Fuel Surcharge - 35</Supplier>
    <Supplier>46081 46150 46250 46280 46286</Supplier>
    <Supplier>Fuel Surcharge - 35451</Supplier>
    <Supplier>46081</Supplier>
</Line>
这里的正则表达式用于提取具有5位数字(带或不带空格)的值,而不考虑迭代

我得到的结果都是真的。意味着它不在某个地方。你能帮我做这件事吗


谢谢。

您的表情有两个问题:

  • XPath表达式末尾没有分号(语法错误)
  • 你的正则表达式是乱七八糟的,它匹配所有不包含字符类括号、数字、花括号、数字5、空格、星号和加号以外的任何内容
  • fn:matches(xs:string?,xs:string)
    需要两个字符串作为参数,您将为第一个字符串传递一系列字符串
要为axis步骤中的每个节点调用函数,请将其作为另一个节点添加(仅限XPath 2.0及更高版本)。您可以在参数中使用点
(上下文)

试试像这样的东西

./Supplier/matches(., "^(\d{5}\s*)+$")

这将为第三行和第五行生成true。如果它只必须包含(而不是完全由)五位数和空格的重复模式,请从正则表达式中删除
^
$

尝试以下操作:
匹配(./Supplier),(.*)(\d{5}(\s*)+)(.*)

./Supplier/matches(., "^(\d{5}\s*)+$")