用于指定字符串长度范围的RegEx:XSD属性元素

Chr*_* V. 4 regex xml xsd xml-attribute

我试图将架构的属性元素限制为3到20个字符长,但是我收到一条错误消息,说我的RegEx无效:

<xs:attribute name="name" use="required">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-Za-Z]{3,20}" />
        </xs:restriction>
    </xs:simpleType>
</xs:attribute>
Run Code Online (Sandbox Code Playgroud)

知道我在这里做错了什么吗?具体错误是"Range end code point is less than the start end code point"

rob*_*nex 5

a-Z是无效的范围,你应该使用小写字母z代替a-z

 <xs:pattern value="[A-Za-z]{3,20}" />
Run Code Online (Sandbox Code Playgroud)

请注意,aascii值为97且Z为90,因此您实际上定义的是从97到90的间隔=>end-point code is lower than the start-point code