在xsd中添加空格reg ex

时间:2014-05-02 20:56:45

标签: xml regex xsd

我有一个xml文件,其中包含以下行。

<asin ISBN="1234567890 1234567890123" code="aB1234Av">

我想用给定的格式写出对ISBN的限制。我的意思是首先是10位数,然后是空格,然后是13位数。我尝试了一个正则表达式,但它不起作用。这是我的xsd。

<xsd:schema  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:element name="asin">

        <xsd:attribute name="ISBN">

            <xsd:simpleType>

                <xsd:restriction base="xsd:integer">

                    <xsd:pattern value="[0-9]{10}[^ ][0-9]{13}"/>

                </xsd:restriction>

            </xsd:simpleType>

        </xsd:attribute>

    </xsd:element>

</xsd:schema>

有人可以帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

[^ ]negated character class,其中包含 空格,请使用[ ]进行尝试,或\s

<xsd:pattern value="[0-9]{10}[ ][0-9]{13}"/>

Demo