强制执行姓氏/名字的 XSD 验证模式 [英] XSD Validation Pattern to Enforce LastName/FirstName

查看:20
本文介绍了强制执行姓氏/名字的 XSD 验证模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要强制使用 LASTNAME/FIRSTNAME 模式,比如 Smith/John.

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.

模式:

 <xsd:pattern value="[a-zA-Z0-9]/[a-zA-Z0-9]"/>

基本上规则是- 斜线之前的任何东西- 斜线后的任何内容- 不应允许像/John"、John/"这样的模式

Basically the rules will be - Anything before the slash - Anything after the slash - Patterns like "/John", "John/" should not be allowed

提前致谢.

推荐答案

ASCII

假设您不想在名称中包含数字:

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]+"/>

请注意,例如,0/0 在这种情况下是有效的.

Be aware that 0/0, for example, would be valid in this case, though.

        <xs:pattern value="\p{L}+/\p{L}+"/>

说明:\p{L} 匹配字母类别中的 Unicode 代码点.

Explanation: \p{L} matches a Unicode code point in the Letter category.

这篇关于强制执行姓氏/名字的 XSD 验证模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆