Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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
Python 替换XML模式中正则表达式的非捕获组?_Python_Regex_Xsd_Lxml_Xsd Validation - Fatal编程技术网

Python 替换XML模式中正则表达式的非捕获组?

Python 替换XML模式中正则表达式的非捕获组?,python,regex,xsd,lxml,xsd-validation,Python,Regex,Xsd,Lxml,Xsd Validation,我正在整理我的第一个自定义XML模式,lxml被捕捉到表示元组的表达式,如10.1,-900: <xs:simpleType name="pair_dec"> <xs:restriction base="xs:string"> <xs:pattern value="-?\d+(?:.\d+),-?\d+(?:.\d+)"/> </xs:restriction> </xs:simpleType> 我读到这

我正在整理我的第一个自定义XML模式,lxml被捕捉到表示元组的表达式,如10.1,-900:

<xs:simpleType name="pair_dec">
    <xs:restriction base="xs:string">
        <xs:pattern value="-?\d+(?:.\d+),-?\d+(?:.\d+)"/>
    </xs:restriction>
</xs:simpleType>

我读到这是因为不支持非捕获组。这是正确的吗?有解决办法吗?

请注意,在XSD正则表达式中:

不支持非捕获组,但可以用捕获组替换 \d和所有其他速记字符类都支持Unicode,因此使用[0-9]而不是\d更安全 必须转义一个点以匹配文字点 使用


正则表达式本身是错误的,您在组后面丢失了。
<xs:pattern value="-?[0-9]+(\.[0-9]+)?,-?[0-9]+(\.[0-9]+)?"/>