title: Regex to use params in path
body: <p>How to create a path that can handle zero, one, the other or both parameters at once (react router v5).</p>
  <p>For example:</p>
  <p><code>/offers /offers/q-shoes /offers/London /offers/London/q-shoes</code></p>
  <p>I am trying to achieve it this way, unfortunately in this case the path <code>/offers/London</code> and <code>/offers</code> is not captured</p>
  <pre><code>import React from 'react';
  import pathToRegexp from 'path-to-regexp';
  import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
  
  import { Home, Browse } from './Pages';
  
  const re = pathToRegexp('/offers/:location?/q-:search?');
  
  const App = () =&gt; (
    &lt;Router&gt;
      &lt;Switch&gt;
        &lt;Route path={re}&gt;
          &lt;Browse /&gt;
        &lt;/Route&gt;
       
        &lt;Route path=&quot;/&quot;&gt;
          &lt;Home /&gt;
        &lt;/Route&gt;
      &lt;/Switch&gt;
    &lt;/Router&gt;
  );
  
  export default App;
  </code></pre>