XML Schema(XSD)1.0 xs:pattern regex可以将4位数字匹配为字符串? [英] XML Schema (XSD) 1.0 xs:pattern regex to match 4 digits as a string?

查看:346
本文介绍了XML Schema(XSD)1.0 xs:pattern regex可以将4位数字匹配为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何匹配特定的数字序列,就好像它是XML模式xs:pattern中的字符串一样?

How can I match a specific sequence of digits as if it were a string in an XML Schema xs:pattern?

说我有一些包含任意10个字符的字符串的标签,例如

Say I have some tags containing arbitrary 10-character strings like

<string>12345678990</string>

我想排除所有带有特定序列的特定黑名单的标签,例如12342435,``9587​​`或类似的东西.

And I want to rule out all tags with a specific blacklist of arbitrary sequences like 1234, 2435, ``9587`, or some such.

如何解决特定的4位数子字符串以求否定并将其添加到xs:pattern内容模型的xs:pattern限制列表中?

How do I address the specific 4-digit sub-string in order to negate it and add it to a list of xs:pattern restrictions for <string>'s content model?

推荐答案

我认为没有任何符合XSD的实用正则表达式可以匹配所有字符串,除了那些包含"1234"作为子字符串的字符串. (因此也无法满足您更具挑战性的禁止多个子字符串的要求.)

I don't think there is any practical XSD-compliant regular expression that will match all strings except those containing "1234" as a substring. (And therefore your more challenging requirement of banning several substrings also cannot be met).

例如,这是XSD 1.1断言的一个

This is one for XSD 1.1 assertions, for example

<xs:assert test="not(contains($value, '1234') or contains($value, '9999'))"/>

这篇关于XML Schema(XSD)1.0 xs:pattern regex可以将4位数字匹配为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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