title: Matching Hubot's name in Coffeescript
body: <p>I want to create a Hubot script which listens for strings that look like:</p>
  
  <pre><code>thanks Hubot
  </code></pre>
  
  <p>where <code>Hubot</code> is the bots name.  If we assume that bot is always named <code>hubot</code>, then it's trivial:</p>
  
  <pre><code>robot.hear /thanks hubot/i, (msg) -&gt; 
      ...
  </code></pre>
  
  <p>But the name of course can vary, though is contained in the <code>robot.name</code> variable.</p>
  
  <p>Question: how do you interpolate the bot's name into the regular expression?  <a href="https://stackoverflow.com/questions/23631638/coffeescript-regex-interpolation">This question</a> seems to indicate you can just use block regular expressions, but I tried:</p>
  
  <pre><code>robot.hear ///thanks #{robot.name}///i, (msg) -&gt;
      ....
  </code></pre>
  
  <p>And it didn't seem to work.</p>
  
  <p>Edit: I have a workaround, I can extract the second word and compare to the bot's name, like so:</p>
  
  <pre><code>  robot.hear /thanks (.*)/i, (msg) -&gt;
      name = msg.match[1]
      if name.toLowerCase() is robot.name.toLowerCase()
        ....
  </code></pre>
  
  <p>But this feels rather kludgy, I'd like to be able to just interpolate a variable into the regex itself.</p>