XSD validation template to enforce LastName / FirstName
I need to force the LASTNAME / FIRSTNAME pattern Something like Smith / John.
Characters can be alphanumeric (lowercase or uppercase) and also include special characters such as "etc."
Pattern:
<xsd:pattern value="[a-zA-Z0-9]/[a-zA-Z0-9]"/>
Basically the rules will be - Anything before the forward slash - Anything after the forward slash - Patterns like "/ John", "John /" should not be allowed
Thanks in advance.
+3
source to share
2 answers
ASCII
Assuming you don't need numbers in names:
<xs:pattern value="[a-zA-Z]+/[a-zA-Z]+"/>
If you really want to accept numbers in names:
<xs:pattern value="[a-zA-Z0-9]+/[a-zA-Z0-9]+"/>
Remember, 0/0
for example, would be valid in this case.
Unicode
<xs:pattern value="\p{L}+/\p{L}+"/>
Explanation : \p{L}
Matches the Unicode code point in the Letter category.
+2
source to share