unicode regex example: trouble

marek markiyan_kushnir at yahoo.com
Fri May 21 03:54:40 EDT 2004


trying this example to make print MatchObject reference. Fails (prints None).
Does anybody know where I am wrong?

# -*- coding: cp1251 -*-

import re

# pattern in Ukrainian ('привіт')
p =                     '\377\376?\004@\0048\0042\004V\004B\004'

# data (pattern is in the middle of the string)
d = '\377\376t\000e\000s\000t\000?\004@\0048\0042\004V\004B\004t\000t\000'

re_test = re.compile(p, re.UNICODE)

print re_test.search(d, re.UNICODE)



More information about the Python-list mailing list