Reputation: 357
I need to write a restriction for a string column, so that it will include 20 letters and 3 of the following : (. , -).
How can this be done?
Thank You.
Upvotes: 2
Views: 3121
Reputation: 17126
Please try this:
<xs:element name="someString">
<xs:simpleType>
<xs:restriction base="xsd:string">
<xs:pattern value="([\w]*[\.\,\-]?[\w]*[\.\,\-]?[\w]*[\.\,\-]?[\w]*)"/>
<xs:length value="23"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Explanation:
[\w\.\,\-]{0,20}
match a single character present in the list below
Quantifier:
Between 0 and 20 times, as many times as possible, giving back as needed [greedy]
So basically this will match all these
The length value="23"
forces that the total string be 23 characters and the regex forces that three characters of the total length be between comma, hyphen and period.
Upvotes: 2