L
L
Lopus2016-04-12 18:10:34
Python
Lopus, 2016-04-12 18:10:34

How to search by cyrillic string in python?

you need to find all the words in the text with a regular routine.
for example:

words = re.findall(r'[a-zA-Za-zA-Z]+', text)

The problem is that text contains a string from the database that contains Cyrillic.
This algorithm above does not work, I tried different options, sometimes something like [u \ .... appears in words. I
forgot about the version: python 2.7, encoding in the utf8_general_ci database

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lopus, 2016-04-12
@Lopus

Done, figured it out
regexp = re.compile(ur'[a-zA-Za-zAZ]+', re.UNICODE)
words = re.findall(regexp, str)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question