how to match u'\uff00' - u'\uff0f' in re module?

MacDonald crazymykl at gmail.com
Mon Jul 10 23:24:24 EDT 2006


yichao.zhang wrote:
> I'm trying to match the characters from u'\uff00' to u'\uff0f'.
> the code below and get a TypeError.
> p = re.compile(u'\uff00'-u'\uff0f')
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> TypeError: unsupported operand type(s) for -: 'unicode' and 'unicode'
>
>
> so re module does NOT support this operation
> however, is there any alternative way to solve my problem?
>
> Any comments/suggestions much appreciated!

re DOES work with unicode, you're just subtracting two unicode stings
as the agrument, which is not defined. Try this:

p = re.compile(u'[\uff00-\uff0f]')




More information about the Python-list mailing list