invalid escape in pattern HTML/Javascript
<p>I am trying to make an <code>&lt;input&gt;</code> field that uses a pattern to check if the input is a valid windows file path.</p>

<p>The pattern I have is</p>

<pre><code>/^(?:[\w]\:|\\)(\\[a-zA-Z_\-\s0-9\.()~!@#$%^&amp;=+';,{}\[\]]+)+\.(exe)$/g
</code></pre>

<p>However, when putting this into the pattern attribute of an <code>&lt;input&gt;</code> field:</p>

<pre><code>&lt;input id="path" type="text" pattern="^(?:[\w]\:|\)(\[a-zA-Z_\-\s0-9\.()~!@#$%^&amp;=+';,{}[]]+)+\.(exe)$"&gt;
</code></pre>

<p>An error is displayed in the console saying:</p>

<pre><code>Pattern attribute value
^(?:[\w]\:|\\)(\\[a-zA-Z_\-\s0-9\.()~!@#$%^&amp;=+';,{}\[\]]+)+\.(exe)$ is
not a valid regular expression:  Uncaught SyntaxError: Invalid regular
expression: /^(?:[\w]\:|\\)(\\[a-zA-Z_\-\s0-9\.()~!@#$%^&amp;=+';,{}\[\]]+)+\.(exe)$/:
Invalid escape
</code></pre>

<p>I have tried several ways of writing this pattern, but none seem to work.</p>