Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegEx for specified string length range : XSD attribute element

I'm trying to restrict an attribute element of a schema to be between 3 and 20 characters long, but I'm getting an error saying my RegEx is invalid:

<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>

Any idea what I'm doing incorrectly here? Specific error is "Range end code point is less than the start end code point"

like image 862
Chris V. Avatar asked Feb 22 '23 18:02

Chris V.


1 Answers

a-Z is the invalid range, you should use the lowercase z instead a-z

 <xs:pattern value="[A-Za-z]{3,20}" />

Note that a ascii value is 97 and Z is 90 so you were actually defining an interval from 97 to 90 => end-point code is lower than the start-point code

like image 123
robertodecurnex Avatar answered Mar 23 '23 12:03

robertodecurnex