简体   繁体   English

XML模式正则表达式

[英]XML Schema Regular Expression

I'm having trouble with two regular expressions that I need to use to validate url s in an xsd file. 我在使用两个正则表达式来验证xsd文件中的url遇到麻烦。

I understand that there is a slight difference in how Schema uses regex compared to other systems. 我知道与其他系统相比, Schema使用regex的方式上略有不同。

Does anyone have any valid regex to separately validate a url and an email in XSD schema? 是否有人有任何有效的正则表达式来分别验证XSD架构中的urlemail

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. 并不是说xsd模式总是暗示着锚点,所以它必须匹配您的整个字符串。

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. 关于URL,取决于您希望验证的复杂程度,可以使用大约一百万个正则表达式。 And schema regex is rather limited to say the least. 模式正则表达式至少可以说是有限的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM