I need to enforce the pattern LASTNAME/FIRSTNAME Something like Smith/John.
The characters can be Alphanumeric (lowercase/uppercase) also includes special characters like ë etc.
Pattern:
<xsd:pattern value="[a-zA-Z0-9]/[a-zA-Z0-9]"/>
Basically the rules will be
- Anything before the slash
- Anything after the slash
- Patterns like "/John", "John/" should not be allowed
Thanks in advance.
ASCII
Assuming that you don't want numbers in the names:
<xs:pattern value="[a-zA-Z]+/[a-zA-Z]+"/>
If you really want to accept numbers in the names:
<xs:pattern value="[a-zA-Z0-9]+/[a-zA-Z0-9]+"/>
Be aware that 0/0
, for example, would be valid in this case, though.
Unicode
<xs:pattern value="\p{L}+/\p{L}+"/>
Explanation: \p{L}
matches a Unicode code point in the Letter category.
Your restriction should be this..
<xs:pattern value="(([a-zA-Z0-9])*)([/])(([a-zA-Z0-9])*)"/>
I validated this pattern by XMLSpear