title: Python Regex for hyphenated words
body: <p>I'm looking for a regex to match hyphenated words in Python.</p>
  <p>The closest I've managed to get is: '\w+-\w+[-w+]*'</p>
  <pre class="lang-py prettyprint-override"><code>text = &quot;one-hundered-and-three- some text foo-bar some--text&quot;
  hyphenated = re.findall(r'\w+-\w+[-\w+]*',text)
  </code></pre>
  <p>which returns list <code>['one-hundered-and-three-', 'foo-bar']</code>.</p>
  <p>This is almost perfect except for the trailing hyphen after <code>'three'</code>. I only want the additional hyphen if followed by a <code>'word'</code>. i.e. instead of the <code>'[-\w+]\*'</code> I need something like <code>'(-\w+)*'</code> which I thought would work, but doesn't (it returns <code>['-three, '']</code>). i.e. something that matches <code>|word</code> followed by hyphen followed by word followed by hyphen_word zero or more times|.</p>