Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I was wondering how to make a regular expression for any character except * and + . I've tried ([^*+]) and ([^*+]) but both expressions seem to be incorrect. Can someone please point me in the right direction? Thanks.

Edit: Here is a code snipet. I've attached the reg ex suggested below into visual studio and it still generates an error when i enter in a regular string.

<xsd:element name="elementName">
    <xsd:simpleType>
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="/^[^*+]+$/"></xsd:pattern>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:element>   

Edit: The example string I'm using is "test" The result is pattern constraint fail with the current reg ex: /^[^*+]+$/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

In the XML Schema regex flavor, you must not add regex delimiters (i.e., the / at either end of /^[^*+]+$/). You also don't need to use anchors (i.e., the ^ at the beginning and $ at the end); all regex matches are automatically anchored at both ends. That line should read:

<xsd:pattern value="[^*+]+"></xsd:pattern>

...meaning the whole element must consist of one or more of any characters except * and +.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...