How to properly escape Regular Expression pattern in XSD schema?
<p>I need to fulfill a requirement to only accept values in the form of MM/DD/YYYY.</p>

<p>From what I've read on: <a href="https://www.w3.org/TR/xmlschema11-2/#nt-dateRep" rel="nofollow">https://www.w3.org/TR/xmlschema11-2/#nt-dateRep</a>
Using   </p>

<pre><code>&lt;xs:simpleType name="DATE"&gt;
        &lt;xs:restriction base="xs:date"/&gt;
    &lt;/xs:simpleType&gt;
</code></pre>

<p>Is not going to work as its regex apparently is not supporting this format.</p>

<p>I have found and adjusted this format:</p>

<pre><code>^(?:(?:(?:0?[13578]|1[02])(\/)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
</code></pre>

<p>To this form:</p>

<pre><code>\^\(\?:\(\?:\(\?:0\?\[13578\]\|1\[02\]\)\(\\/\)31\)\1\|\(\?:\(\?:0\?\[1,3-9\]\|1\[0-2\]\)\(\\/\)\(\?:29\|30\)\2\)\)\(\?:\(\?:1\[6-9\]\|\[2-9\]\d\)\?\d{2}\)$\|\^\(\?:0\?2\(\\/\)29\3\(\?:\(\?:\(\?:1\[6-9\]\|\[2-9\]\d\)\?\(\?:0\[48\]\|\[2468\]\[048\]\|\[13579\]\[26\]\)\|\(\?:\(\?:16\|\[2468\]\[048\]\|\[3579\]\[26\]\)00\)\)\)\)$\|\^\(\?:\(\?:0\?\[1-9\]\)\|\(\?:1\[0-2\]\)\)\(\\/\)\(\?:0\?\[1-9\]\|1\d\|2\[0-8\]\)\4\(\?:\(\?:1\[6-9\]\|\[2-9\]\d\)\?\d{2}\)$
</code></pre>

<p>Now I no longer get invalid escaping errors in XML editors (using XML Spy), but I get this one: </p>

<pre><code>invalid-escape: The given character escape is not recognized.
</code></pre>

<p>I have done the escape according to the XML schema specifications here:
<a href="https://www.w3.org/TR/xmlschema-2/#regexs" rel="nofollow">https://www.w3.org/TR/xmlschema-2/#regexs</a> Section F.1.1 there is an escape table.</p>

<p>Can anyone please help to nail this down right?</p>

<p>Thanks!</p>