I am writing XSD pattern restriction and I have the following strings that are valid
And the below are invalid
The rule is to start the string with either ^ or {. If we start with { then next character should be $ and the word should end with }. No uppercase or @ symbol allowed.
I have tried this <xs:pattern value="[\\^\\{].*\\w+\\}?"/>
this work partially but doesnt satisfy all conditions
Any help is appreciated.
You may use
<xs:attribute name="label">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\^[a-z]+(\.[a-z]+)?|\{\$[a-z]+(\.[a-z]+)?}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
XSD regex are always anchored, so the two alternatives in the above regex must match the whole string.
They match
\\^[az]+(\\.[az]+)?
- ^
char, then 1+ lowercase ASCII letters, then an optional sequence of .
and 1+ lowercase ASCII letters|
- or \\{\\$
- {$
substring [az]+(\\.[az]+)?
- 1+ lowercase ASCII letters, then an optional sequence of .
and 1+ lowercase ASCII letters}
- a }
char.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.