title: Writing a regex for an Express route which has a variable number of parameters
body: <p>I'm building an API, and trying to allow the user to 'filter' the result set using any combination of parameters.</p>
  
  <p>We have 2 cats, each with 4 properties: <em>name</em>, <em>age</em>, <em>sex</em> and <em>color</em>.</p>
  
  <p><code>cat1 = {'name': 'Fred', 'age': '10', 'sex': 'male', 'color': 'white'}</code></p>
  
  <p><code>cat2 = {'name': 'Alex', 'age': '10', 'sex': 'male', 'color': 'black'}</code></p>
  
  <p>I'd like a <strong>single</strong> route to match any combination of the parameters the user chooses to apply to their search. For example, the route would match the following (as well as any other combination):</p>
  
  <p><code>router.get('/name/:name/age/:age/sex/:sex/color/:color', ...){}</code></p>
  
  <p><code>router.get('/name/:name/age/:age/sex/:sex', ...){}</code></p>
  
  <p><code>router.get('/age/:age/color/:color', ...){}</code></p>
  
  <p>Essentially, all parameters are optional.</p>
  
  <p>I think regex is the best way to go - how can I do this?</p>