title: How to use regex to constrain a ReactJS Route
body: <p>As said in <a href="https://stackoverflow.com/questions/1687620/regex-match-everything-but">Regex: match everything but</a> in order to match everything but a string, you can use <code>^(?!foo$).*</code></p>
  
  <p>As seen here
  <a href="https://regex101.com/r/9khSXB/2" rel="nofollow noreferrer">https://regex101.com/r/9khSXB/2</a></p>
  
  <p>But this doesn't work when using <a href="https://www.npmjs.com/package/path-to-regexp" rel="nofollow noreferrer">https://www.npmjs.com/package/path-to-regexp</a> specifically within ReactJS Routing (error -> invalid path)</p>
  
  <pre><code>&lt;R.Route path="/^(?!\/whatsmyname$).*" render={() =&gt; &lt;div&gt;works!&lt;/div&gt;} /&gt;
  </code></pre>
  
  <p>(also seen here <a href="http://forbeslindesay.github.io/express-route-tester/" rel="nofollow noreferrer">http://forbeslindesay.github.io/express-route-tester/</a>)</p>
  
  <p>How can I write this regex in a node-friendly style?</p>
  
  <p>UPDATE: this does work, you need the curly braces</p>
  
  <pre><code>&lt;R.Route path={/^\/(?!whatsmyname$).*/} render={() =&gt; &lt;div&gt;works!&lt;/div&gt;} /&gt;
  </code></pre>