title: Python - regex - special characters and ñ
body: <p>I have this script to test a regex and how unicode behaves:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import re
  
  p = "Solo voy si se sucedierón o se suceden mañana los siguienñes eventos:"
  
  w = re.findall('[a-zA-ZÑñ]+',p.decode('utf-8'), re.UNICODE)
  
  print(w)
  </code></pre>
  
  <p>And the <code>print</code> statement is showing this:</p>
  
  <pre><code>[u'Solo', u'voy', u'si', u'se', u'sucedier', u'n', u'o', u'se', u'suceden', u'ma', u'ana', u'los', u'siguien', u'es', u'eventos']
  </code></pre>
  
  <p><code>"sucedierón"</code> is being transformed to <code>"u'sucedier', u'n'"</code>, and similarly <code>"mañana"</code>  becomes <code>"u'ma', u'ana'"</code>.</p>
  
  <p>I have tried decoding, adding <code>'\xc3\xb1a'</code> to the regex for <code>'Ñ'</code></p>
  
  <p>Later after reading some docs I realized that using <code>[a-zA-Z]</code> just matches ASCII character. That is why I had to change to <code>r'\b\w+\b'</code> so I can add flags to the regex</p>
  
  <pre><code>w = re.findall(r'\b\w+\b', p, re.UNICODE) 
  </code></pre>
  
  <p>But this didn't work.</p>
  
  <p>I also tried to <code>decode()</code> first and <code>findall()</code> later:</p>
  
  <pre><code>p = "Solo voy si se sucedierón o se suceden mañana los siguienñes eventos:"
  U = p.decode('utf8')
  </code></pre>
  
  <p>If I print variable <code>U</code></p>
  
  <pre><code>"Solo voy si se sucedierón o se suceden mañana los siguienñes eventos:"
  </code></pre>
  
  <p>I see that the output is as expected, but when I use the <code>findall()</code> again:</p>
  
  <pre><code>[u'Solo', u'voy', u'si', u'se', u'sucedier\xf3n', u'o', u'se', u'suceden', u'ma\xf1ana', u'los', u'siguien\xf1es', u'eventos']
  </code></pre>
  
  <p>Now the word is complete but <code>ó</code> is replaced with <code>\xf3n</code> and <code>ñ</code> is replaced with <code>\xf1</code>, unicode values.</p>
  
  <p>How can I <code>findall()</code> and get the non-ASCII characters <code>"ñ","á", "é", "í", "ó", "ú"</code></p>
  
  <p>I now there are a lot of this kind of questions in SO, and believe me I read a lot of them, but i just cannot find the missing part.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am using python 2.7</p>
  
  <p><strong>EDIT 2</strong>
  Can someone else try what @LetzerWille suggest? Is not working for me </p>