xmlxsdxml-parsingxsd-validationxsd2code

InvalidRegex: Pattern value '(?:Y|N)' is not a valid regular expression.


I have used regular expression for yes no type. but compiler throwing exception like this.

<xsd:simpleType name="YesNoType">
        <xsd:annotation>
            <xsd:documentation>
                Type for yes and no inputs.
            </xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
                <xsd:pattern value="(?:Y|N)"/>
        </xsd:restriction>
</xsd:simpleType>

InvalidRegex: Pattern value '(?:Y|N)' is not a valid regular expression. The reported error was: 'This expression is not supported in the current option setting.'.

Please help me regarding this.


Solution

  • Just replace it with something simpler like

    Y|N
    

    Or

    [YN] 
    

    Or the like.

    Non-capturing parens are not implemented in all versions of regex.