title: Python: Regex for words and hyphens
body: <p>I'm using an API which until recently returned a dictionary with variables in the form of {{variable_name}}. I would then translate those variables into my own strings using a translation dictionary and this line:</p>
  
  <pre><code>new_string = re.sub(r"\{\{(\w+)\}\}", lambda m: translator[m.group(1)], raw_string)
  </code></pre>
  
  <p>However the API has changed, and for some odd reason now the variables are with hyphens instead of underscores, like {{variable-name}}.</p>
  
  <p>Now with the hyphen my regex isn't matching, and after endless attempts to fix that and reviewing other Stack Overflow questions which failed me, I'm not sure what else I can try.</p>
  
  <p>Long story short, I'm trying to match any series of word characters (letters, numbers, and underscore) and the hyphen character, surrounded by double curly brackets. </p>