How to match alphanumeric characters in python regexp?
<p>I’d like to get all the words from a text, including unicode characters, not including hyphens or underscores or any other non-alphanumeric characters.</p>

<p>I.e. I want something like this:</p>

<pre><code>&gt;&gt;&gt; getWords('John eats apple_pie')
['John', 'eats', 'apple', 'pie']
&gt;&gt;&gt; getWords(u'André eats apple-pie')
[u'André', u'eats', u'apple', u'pie']
</code></pre>

<p>With</p>

<pre><code>getWords = lambda text: re.compile(r'[A-Za-z0-9]+').findall(text)
</code></pre>

<p>it works for the first example, but not the second, and the other way around with this:</p>

<pre><code>getWords = lambda text: re.compile(r'\w+', re.UNICODE).findall(text)
</code></pre>