XML Schema regex to allow for a character to appear consecutively but reject if appears only once



The below simpleType has a pattern value = "[^*]*" , which rejects any occurrence of an asterisk in the string, which is the character we designated to blank out the corresponding database column:



<xsd:simpleType name="StringMin1Max80TypeBase">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="80"/>
<xsd:pattern value="[^\*]*"/>
</xsd:restriction>
</xsd:simpleType>


Some of our simpleTypes don't have this pattern value in order to allow people to enter the * . Someone recently submitted an element with the above type that has this string: **WARNING** , so this element was rejected unintentionally. Is there a way to allow for consecutive characters like ** or ***, etc., but reject the appearance of exactly one character? I know XML Schema regular expressions do not use negative lookbehind and negative lookahead and the characters < and ? are not allowed in the pattern value.


If this is possible, how about also allowing *string* , i.e., multiple characters but not one?


Thanks a lot.


No comments:

Post a Comment