Regular Expression to restrict a field in schema - Pls advise
905784Apr 12 2012 — edited Apr 17 2012Hello All,
I am trying to restrict a field in the schema which must follow below conditions:
1. field must start with alphanumeric characters but not with spaces(*<element>abcde</element>* is allowed but *<element></element>* or *<element> </element>* is not allowed)
2. field can have spaces in between or at the end of the field(*<element>abcde </element>*)
I tried using this but it is allowing the field if it is having more than 1 spaces i.e(<element> </element>):
<xsd:simpleType name="myElement">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
also I tried using this but it is not allowing any spaces:
<xsd:simpleType name="myElement">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd :pattern value="[^\r\n\t ]*"/>
</xsd:restriction>
</xsd:simpleType>
Please share your thoughts if we can create one.
Thanks in advance.