python - Regex only searching for words -


i have regex works fine in http://regexpal.com/:

[^-:1234567890/.,\s]* 

i trying find in paragraph full of ( , . # "" \n \s...etc) words

but in code cannot see result specting:

def words(lines):     words_pattern = re.compile(r'[^-:1234567890/.,\s]*')     li = []     m in lines:         e = words_pattern.search(m)         if e:             match = e.group()             li.append(match)     return li  li = [u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u'', u''] 

any advice on this? maybe not traspassing regex in right way 1 place another

thanks in advance

edit

to more precise want: ñ á é í ó , ú

thanks

if want letters use string.ascii_letters

>>> string import ascii_letters >>> import re >>> s = 'this 123 text! has someñ \n other stuff.' >>> re.findall('[{}]+'.format(ascii_letters), s) ['this', 'is', 'some', 'text', 'that', 'has', 'some', 'other', 'stuff'] 

you can same behavior [a-za-z] (which same thing string.ascii_letters)

>>> re.findall('[a-za-z]+', s) ['this', 'is', 'some', 'text', 'that', 'has', 'some', 'other', 'stuff'] 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -