I am searching some simple Cyrillic patterns in strings using python. The pattern I am using is like /[а-я]+/[а-я]+. When I search pattern by this code
import re
re.search('/[а-я]+/[а-я]+', '/бцршб/бйцбйц')
It cannot find anything. But when I write it like this.
import re
re.search(u'/[а-я]+/[а-я]+', u'/бцршб/бйцбйц')
It works. However in my case, the pattern and text are predefined in Database, so I couldn't find a way to convert them to the Unicode string. What is the solution in this case. Any help would be appreciated.
decode()on strings, it would give youAttributeError: 'str' object has no attribute 'decode'.