Case-insensitive regex in XSD

时间:2015-05-24 21:35:26

标签: regex xsd

Is there a better way to do the following?

<xs:restriction base="xs:string">
    <xs:pattern value="hulu|Hulu|netflix|Netflix"></xs:pattern>
</xs:restriction>

Basically I want a case-insensitive match on the word.

2 个答案:

答案 0 :(得分:5)

XML Schema (XSD) does not provide a case-insensitive matching mode for its facet regular expressions. You can simply match both cases explicitly:

<xs:restriction base="xs:string">
    <xs:pattern value="[Hh][Uu][Ll][Uu]"/>
    <xs:pattern value="[Nn][Ee][Tt][Ff][Ll][Ii][Xx]"/>
</xs:restriction>

答案 1 :(得分:0)

You could do [Hh]ulu|[Nn]etflix