Does pyparsing support UNICODE strings?
could ildg
could.net at gmail.com
Thu Aug 4 04:49:48 EDT 2005
I want to parse some Chinese words.
It seems that pyparsing doesn't work for me.
Thank you.
I have to use re directly, although it's harder, but it'll always work.
On 8/4/05, Robert Kern <rkern at ucsd.edu> wrote:
> could ildg wrote:
> > pyparsing is very convenient to use. But I want to find some a py tool
> > to parse non-English strings. Does pyparsing support UNICODE strings?
> > If not, can someone tell me what py tool can do it? Thanks in advance.
>
> Try it!
>
> # vim:fileencoding=utf-8
>
> from pyparsing import Word
>
> text = "Καλημέρα, κόσμε!".decode('utf-8')
> alphas = u''.join(unichr(x) for x in xrange(0x386, 0x3ce))
>
> greet = Word(alphas) + u',' + Word(alphas) + u'!'
> greeting = greet.parseString(text)
> print greeting
>
> --
> Robert Kern
> rkern at ucsd.edu
>
> "In the fields of hell where the grass grows high
> Are the graves of dreams allowed to die."
> -- Richard Harter
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list