fork(3) download
  1. # -*- coding: utf-8 -*-
  2. # http://stackoverflow.com/q/32872917/5290909
  3. #python 2.7.9
  4.  
  5. import re
  6.  
  7. text = "Solo voy si se sucedierón o se suceden mañana los siguienñes eventos:"
  8. # Decode to unicode
  9. unicode_text = text.decode('utf8')
  10.  
  11. matches = re.findall(ur'\b\w+\b', unicode_text, re.UNICODE)
  12.  
  13. # Encode back again to UTF-8
  14. utf8_matches = [ match.encode('utf-8') for match in matches ]
  15.  
  16. # Print every word
  17. for utf8_word in utf8_matches:
  18. print utf8_word
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
Solo
voy
si
se
sucedierón
o
se
suceden
mañana
los
siguienñes
eventos