From cd761d30e64c1ecaf3518087efe2f96df052c4fc Mon Sep 17 00:00:00 2001 From: ptmcg Date: Sat, 27 Oct 2018 12:21:59 -0500 Subject: Add unicode character ranges by name --- examples/greetingInKorean.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'examples/greetingInKorean.py') diff --git a/examples/greetingInKorean.py b/examples/greetingInKorean.py index e48cc8b..2e9d4a1 100644 --- a/examples/greetingInKorean.py +++ b/examples/greetingInKorean.py @@ -6,17 +6,16 @@ # # Copyright 2004-2016, by Paul McGuire # -from pyparsing import Word, srange +from pyparsing import Word, pyparsing_unicode -koreanChars = srange(r"[\0xac00-\0xd7a3]") -koreanWord = Word(koreanChars,min=2) +koreanChars = pyparsing_unicode.Korean.alphas +koreanWord = Word(koreanChars, min=2) # define grammar greet = koreanWord + "," + koreanWord + "!" # input string -hello = '\uc548\ub155, \uc5ec\ub7ec\ubd84!' #"Hello, World!" in Korean +hello = '안녕, 여러분!' #"Hello, World!" in Korean # parse input string -print(greet.parseString( hello )) - +print(greet.parseString(hello)) -- cgit v1.2.1