title: How to do pattern matching and parsing strings in javascript without regex
body: <p>I am writing a bot in Node and would like an easy way to match <em>AND</em> parse incoming requests. I would like to do something similar to this:</p>
  
  <pre><code>var message = "What's the weather in Timbuktu?"; //comes from bot
  var patterns = [];
  patterns.push({intent:"weather", pattern:"[what's|what is|how's|how is|][the|]weather[in|]{?location}"}];
  patterns.push({intent:"time", pattern:"[what's|what is|what][the|]time[is it in|in|]{?location}"}];
  var result= getIntent(patterns, message);
  </code></pre>
  
  <p>In this example, the expected value of result would be:</p>
  
  <pre><code>{intent:'weather', data:{location:'Timbuktu'}}
  </code></pre>
  
  <p>I've done a bit a digging for such a beast, but most solutions involve regex.  I'm not totally opposed to that, but think in this case something simpler and more human-readable would be better.  This is similar to how Amazon Alexa parses utterances, but I'm hoping for something generic that could be used with various bot APIs.  <a href="https://github.com/alexa-js/alexa-utterances" rel="nofollow noreferrer">alexa-utterances</a> comes close, but is only for expanding the pattern, not parsing and providing the slot values.</p>