XML 模式正则表达式

发布于 2024-12-08 19:25:11 字数 227 浏览 0 评论 0原文

我在使用两个正则表达式时遇到问题,需要使用这两个正则表达式来验证 xsd 文件中的 url

据我所知,与其他系统相比,Schema 使用正则表达式的方式略有不同。

有没有人有任何有效的正则表达式来单独验证 XSD 架构中的 urlemail

I'm having trouble with two regular expressions that I need to use to validate urls in an xsd file.

I understand that there is a slight difference in how Schema uses regex compared to other systems.

Does anyone have any valid regex to separately validate a url and an email in XSD schema?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ˇ宁静的妩媚 2024-12-15 19:25:11

对于电子邮件:

<xsd:pattern value="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}"/>

xsd 模式并不总是暗示锚点,因此这应该与您的整个字符串匹配。

编辑:上面的正则表达式非常基本。我建议您阅读以下内容:

使用正则表达式进行验证电子邮件地址

了解更多信息。关于 url,根据您希望验证的复杂程度,您可以使用大约一百万个正则表达式。至少可以说,模式正则表达式相当有限。

For e-mail :

<xsd:pattern value="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}"/>

Not that xsd schema always implies anchors so this should have to match your entire string.

Edit : Above regex is pretty basic. I suggest you read this :

Using a regular expression to validate an email address

For more info. Regarding the url, depending on how complex you want your validation to be there are about a million regexes you could use. And schema regex is rather limited to say the least.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文