diff options
author | ptmcg <ptmcg@austin.rr.com> | 2018-10-27 12:21:59 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2018-10-27 12:21:59 -0500 |
commit | cd761d30e64c1ecaf3518087efe2f96df052c4fc (patch) | |
tree | fe2ab5e5b3942ab47af11825f680da5347663fcd /examples | |
parent | ddd2ee7e9fcf5e5b7de6f1672d32ce8e5f94348d (diff) | |
download | pyparsing-git-cd761d30e64c1ecaf3518087efe2f96df052c4fc.tar.gz |
Add unicode character ranges by name
Diffstat (limited to 'examples')
-rw-r--r-- | examples/greetingInGreek.py | 8 | ||||
-rw-r--r-- | examples/greetingInKorean.py | 11 |
2 files changed, 9 insertions, 10 deletions
diff --git a/examples/greetingInGreek.py b/examples/greetingInGreek.py index c4d002f..921ac04 100644 --- a/examples/greetingInGreek.py +++ b/examples/greetingInGreek.py @@ -6,15 +6,15 @@ #
# Copyright 2004-2016, by Paul McGuire
#
-from pyparsing import Word
+from pyparsing import Word, pyparsing_unicode
# define grammar
-alphas = ''.join(chr(x) for x in range(0x386, 0x3ce))
+alphas = pyparsing_unicode.Greek.alphas
greet = Word(alphas) + ',' + Word(alphas) + '!'
# input string
-hello = "Καλημέρα, κόσμε!".decode('utf-8')
+hello = "Καλημέρα, κόσμε!"
# parse input string
-print(greet.parseString( hello ))
+print(greet.parseString(hello))
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))
|