[Tutor] the regex boundary about chinese word

goog cheng googcheng at gmail.com
Fri May 4 05:38:39 CEST 2012


Hi,  I got this problem :

#!python
# -*- coding: utf-8 -*-
import re

p = re.compile(ur'\bc123\b')
print '**',p.search('no class c123 at all').group()

p = re.compile(ur'\b\u7a0b\u6770\b')
print ur'\u7a0b\u6770'
print '****',p.search(' 程杰 abc'.decode('utf8'))

why the  \b   boundary  can't match the word '程杰'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120504/9e5f45bf/attachment.html>


More information about the Tutor mailing list