我们要求在 XSD 元素中允许除 #、$ 和空格之外的所有字符(包括特殊字符)。
我试过正则表达式,[^$#\s]*
但没有用。你能帮忙解决这个问题,因为我无法弄清楚。
我在 XSD 中尝试了你的正则表达式,它按预期工作。
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO53903548" targetNamespace="http://Scratch.SO53903548" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="SpecialString2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[^$#\s]*" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
会很高兴地验证下面的内容,但在 $,# 或空格上失败
<ns0:Root xmlns:ns0="http://Scratch.SO53903548">
<SpecialString2>thequickbrownfoxjumpedoverthelazydog@THEQUICKBROWNFOXJUMPEDOVERTHELAZYDOG!~`@%^&*()-_+=</SpecialString2>
</ns0:Root>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句