In xml, i have a tag say <membercode>
The regex pattern for the field currently is <xs:pattern value="[a-zA-Z0-9\s]{1,3}" />
The membercode must accept values as follows:
1) "XY" -> pass
2) "XY " -> pass
3) " " -> i need to have this failed. but it is getting passed.
4) " XY " -> need to be failed
EDIT: Requirements:
1) total allowed characters must be maximum 3.
2) With in the allowed 3 chars, there can be spaces. ex: "XY", "XY "," XY" , "X "
3) But if the total chars exceed 3 or if there is only spaces(no alphanumeric chars) then it should not be allowed.
tried whitespace collapse property, but in that case the maxlength is applied after the collapse is done. so values more than max length is also allowed.
hence tried below things..
<xs:pattern value="[a-zA-Z0-9]{1,3}[\s?]" />
<xs:pattern value="[a-zA-Z0-9]{1,3}|[a-zA-Z0-9\s?]{1,3}" />
but couldn't get hold on the correct solution.
Please point me the correct approach for this..
Many thanks for the suggestions!