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: /^[^*+]+$/
You can define regular expressions for input validation in separate XML files. Reference to these regular expressions can be used in multiple data types that are defined in the datatypes. xml file.
$ means "Match the end of the string" (the position after the last character in the string).
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 +
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With